将比较重要的 log 记数据库

@param string $sType 日志类型，参见 getType()
@param array $aMessage 日志内容
@static
@access public
@throws TangoException
@return bool
189565
public static function collection($sType, array $aMessage) {

		self::$_iStep++;
		if (self::$_iStep > 1000) {
			return FALSE;
		}

		if (!self::init()) {
			return FALSE;
		}

		$iType = array_search((string)$sType, self::$_lType);
		if (!$iType) {
			throw new TangoException('unknown type "'.$sType.'"');
		}

		$oDB = DB::getInstance('_debug');
		if (!self::$_iAI) {
			self::$_iAI = $oDB->genAI('id_gen');
		}

		if (self::$_iStep == 1) {
			$aMessage['_init'] = [
				'sapi' => PHP_SAPI,
				'server_ip' => $_SERVER['SERVER_ADDR'],
				'client_ip' => $_SERVER['REMOTE_ADDR'],
				'uri' => $_SERVER['REQUEST_URI'],
				'time' => $_SERVER['REQUEST_TIME'],
				'elapsed' => microtime(TRUE) - $_SERVER['REQUEST_TIME_FLOAT'],
			];
		}

		$sQuery = 'INSERT INTO log '
			.'SET id = '.self::$_iAI.', '
			.'step = '.self::$_iStep.', '
			.'type = '.$iType.', '
			.'data = 0x'.bin2hex(gzcompress(json_encode($aMessage, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)));
		return $oDB->exec($sQuery);
	}
1243125
def _get_primary_type(ttypes, parent, logstream=stderr):
    """"""
    if len(ttypes) > 1:
        if logstream:  # pragma: no branch
            message = '[tag::transcript::primary_transcript]'
            message += ' WARNING: feature {:s}'.format(parent.slug)
            message += ' has multiple associated transcript types'
            message += ' {}'.format(ttypes)
            print(message, file=logstream)
        if 'mRNA' not in ttypes:
            message = (
                'cannot resolve multiple transcript types if "mRNA" is'
                ' not one of those types {}'.format(ttypes)
            )
            raise Exception(message)
        ttypes = ['mRNA']
    return ttypes[0]
1242780
public static function dump($sType, $sMessage = NULL, $bHead = FALSE) {
		if ($sMessage === NULL) {
			return ;
		}
		self::_file($sType, $sMessage, $bHead, LOCK_EX);
	}
310974
function show_message($message, $type = 'notice', $vars = null, $override = true, $timeout = 0)
    {
        if ($this->app->text_exists($message)) {
            $message = $this->app->gettext(array('name' => $message, 'vars' => $vars));
        }

        printf("[%s] %s\n", strtoupper($type), $message);
    }
404372
public function _serializeConfVar($sType, $sName, $mValue)
    {
        $sData = $mValue;

        switch ($sType) {
            case "bool":
                break;

            case "str":
            case "select":
            case "int":
                if (in_array($sName, $this->_aParseFloat)) {
                    $sData = str_replace(',', '.', $sData);
                }
                break;

            case "arr":
                if (!is_array($mValue)) {
                    $sData = $this->_multilineToArray($mValue);
                }
                break;

            case "aarr":
                $sData = $this->_multilineToAarray($mValue);
                break;
        }

        return $sData;
    }
1317127
public function getTypeBySlug($sSlug)
    {
        return isset($this->aEventTypes[$sSlug]) ? $this->aEventTypes[$sSlug] : false;
    }
135066
private function changelog ($type)
	{
		
		// If changelog or type is disabled for the class return FALSE
		
		if (isset (static::$changelogIgnore))
		{
			
			if (static::$changelogIgnore === TRUE || 
				is_array (static::$changelogIgnore) && in_array ($type, static::$changelogIgnore))
			{
				return FALSE;
			}
			
		}
		
		// If there is no changelog resource defined or we're dealing with a changelog object return FALSE
		
		if (!($this->getResource ('changelog') instanceof Resource\Change\Log) || 
			$this instanceof Resource\Change\Log || $this instanceof Resource\Change\Log\Column)
		{
			return FALSE;
		}
		
		// Default return TRUE
		
		return TRUE;
		
	}
1197552
protected static function _log($type, array $args)
    {
        // nothing passed in, don't do anything
        if (count($args) == 0 && $type != self::GROUP_END) {
            return;
        }

        $logger = self::getInstance();

        $logger->_processed = array();

        $logs = array();
        foreach ($args as $arg) {
            $logs[] = $logger->_convert($arg);
        }

        $backtrace = debug_backtrace(false);
        $level = $logger->getSetting(self::BACKTRACE_LEVEL);

        $backtrace_message = 'unknown';
        if (isset($backtrace[$level]['file']) && isset($backtrace[$level]['line'])) {
            $backtrace_message = $backtrace[$level]['file'] . ' : ' . $backtrace[$level]['line'];
        }

        $logger->_addRow($logs, $backtrace_message, $type);
    }
412667
public function record($msg, $type = 'info', array $context = [])
    {
        if (is_string($msg)) {
            $replace = [];
            foreach ($context as $key => $val) {
                $replace['{' . $key . '}'] = $val;
            }

            $msg = strtr($msg, $replace);
        }

        $this->log[$type][] = $msg;

        if (PHP_SAPI == 'cli') {
            // 命令行日志实时写入
            $this->save();
        }

        return $this;
    }
722739
private function logCreate(\Swift_Mime_SimpleMessage $message, $status, $templateID, $language)
    {
        // Check Message
        if (null === $message->getId() || empty($message->getId())) {
            return false;
        }

        // Create Log
        $class = $this->bag->get('pd_mailer.mail_log_class');
        $this->log = new $class;
        $this->log->setMailId($message->getId());
        $this->log->setFrom($message->getFrom());
        $this->log->setTo($message->getTo());
        $this->log->setSubject($message->getSubject());
        $this->log->setBody($message->getBody());
        $this->log->setContentType($message->getContentType());
        $this->log->setDate($message->getDate());
        $this->log->setHeader($message->getHeaders()->toString());
        $this->log->setReplyTo($message->getReplyTo());
        $this->log->setStatus($status);
        $this->log->setTemplateId($templateID);
        $this->log->setLanguage($language);

        // Save
        $this->entityManager->persist($this->log);
        $this->entityManager->flush();

        return true;
    }
55633
public function log($str, $type = 'notice', $data = [])
    {
        $log = new \Monolog\Logger('task_log');
        
        //add file handler - log to file
        $log->pushHandler(
            new \Monolog\Handler\StreamHandler('logs/'.date('Y-m-d').'.log')
        );
        
        $method = 'add'.$type;
        if (method_exists($log, $type)) {
            $log->$method($str, $data);
        }
    }
112322
void check_type() throws DevFailed
	{
		boolean unsuported = true;
		if (type == Tango_DEV_SHORT)
			unsuported = false;
		else if (type == Tango_DEV_USHORT)
			unsuported = false;
		else if (type == Tango_DEV_LONG)
			unsuported = false;
		else if (type == Tango_DEV_LONG64)
			unsuported = false;
		else if (type == Tango_DEV_ULONG)
			unsuported = false;
		else if (type == Tango_DEV_ULONG64)
			unsuported = false;
		else if (type == Tango_DEV_BOOLEAN)
			unsuported = false;
		else if (type == Tango_DEV_FLOAT)
			unsuported = false;
		else if (type == Tango_DEV_DOUBLE)
			unsuported = false;
		else if (type == Tango_DEV_STRING)
			unsuported = false;
		else if (type == Tango_DEV_STATE)
			unsuported = false;
		else if (type == Tango_DEV_ENCODED)
			unsuported = false;

		if (unsuported == true)
		{
			Util.out3.println("Attr.check_type throwing exception");
		
			StringBuffer o = new StringBuffer("Attribute : ");
			o.append(name).append(": Data type is not supported");
			Except.throw_exception("API_AttrWrongDefined",
				    o.toString(),
					"Attr.check_type");
		}
	}
1167186
public static function getPhpType($type)
    {
        switch ($type) {
            case self::TYPE_DOUBLE:
            case self::TYPE_FLOAT:
                return 'float';
            case self::TYPE_INT64:
            case self::TYPE_UINT64:
            case self::TYPE_INT32:
            case self::TYPE_FIXED64:
            case self::TYPE_FIXED32:
            case self::TYPE_UINT32:
            case self::TYPE_SFIXED32:
            case self::TYPE_SFIXED64:
            case self::TYPE_SINT32:
            case self::TYPE_SINT64:
                return 'int';
            case self::TYPE_BOOL:
                return 'bool';
            case self::TYPE_STRING:
                return 'string';
            case self::TYPE_BYTES:
                return '\Protobuf\Stream';
            default:
                return null;
        }
    }
991071
function log(type) {
  var messages = Array.prototype.slice.call(arguments);
  messages.shift();
  // Concatenate default strings and first message argument into
  // one string so we can use `printf`-like replacement
  var first = "JPM [" + type + "] " + (messages.shift() + "");

  if (process.env.NODE_ENV !== "test") {
    console.log.apply(console, [first].concat(messages)); // eslint-disable-line no-console
  }
}
795164
private function checkForCorrectMessageType()
    {
        $type = $this->getMandatoryField("Type");
        if (strcasecmp($type, "Notification") != 0) {
            throw new \Exception("Error with SNS Notification - unexpected message with Type of " . $type);
        }

        if (strcmp($this->getMandatoryField("Type"), "Notification") != 0) {
            throw new \Exception("Error with signature verification - unable to verify " . $this->getMandatoryField("Type") . " message");
        } else {

            // Sort the fields into byte order based on the key name(A-Za-z)
            ksort($this->fields);

            // Extract the key value pairs and sort in byte order
            $signatureFields = array();
            foreach ($this->fields as $fieldName => $mandatoryField) {
                if ($mandatoryField) {
                    $value = $this->getMandatoryField($fieldName);
                } else {
                    $value = $this->getField($fieldName);
                }

                if (!is_null($value)) {
                    array_push($signatureFields, $fieldName);
                    array_push($signatureFields, $value);
                }
            }

            /* Create the signature string - key / value in byte order
             * delimited by newline character + ending with a new line character
             */
            $this->signatureFields = implode("\n", $signatureFields) . "\n";
        }
    }
833027
private static function createLogger($type) {
        $Logger = new Logger($type);

        foreach (Config::getInstance()->get('logger', 'handlers') as $handlerType => $handlerConfig) {
            $Handler = static::createHandler($handlerType, $handlerConfig);
            if (!$Handler) {
                continue;
            }
            $Handler->setFormatter(static::createLogFormatter($handlerConfig));
            $Logger->pushHandler($Handler);
        }

        $Logger->pushProcessor(new GlobalContextProcessor());
        return $Logger;
    }
1122454
private static function _log($msgType, $args)
    {
        if (!Config::getField('project', 'debug_mode', 0)) {
            return;
        }

        if (count($args) == 1) {
            $msg = is_scalar($args[0]) ? $args[0] : self::dump($args[0]);
        } else {
            $msg = self::dump($args);
        }

        if (self::$DEBUG_TRACE) {
            $trace = self::getTrace();
        } else {
            $trace = array();
        }
        if ($msgType == 'debug') {
            Terminal::drawStr($msg, 'magenta');
        } else if ($msgType == 'error') {
            Terminal::drawStr($msg, 'red');
        } else if ($msgType == 'info') {
            Terminal::drawStr($msg, 'brown');
        } else {
            Terminal::drawStr($msg, 'default');
        }
        //echo "\n";
        !empty($trace) && Terminal::drawStr("\t" . implode(" <-- ", $trace) . "\n");
    }