public static function log(string $msg, array $data = [], int $level = self::VERB_DEBUG, array $opts = []): void
    {
        $levelName  = self::LEVEL_NAMES[$level] ?? 'INFO';
        $colorName  = self::LEVEL2TAG[$level] ?? 'info';
        $taggedName = ColorTag::add($levelName, $colorName);

        $userOpts = [];
        foreach ($opts as $n => $v) {
            if (\is_numeric($n) || \strpos($n, '_') === 0) {
                $userOpts[] = "[$v]";
            } else {
                $userOpts[] = "[$n:$v]";
            }
        }

        $optString = $userOpts ? ' ' . \implode(' ', $userOpts) : '';

        self::write(\sprintf(
            '%s [%s]%s %s %s',
            \date('Y/m/d H:i:s'),
            $taggedName,
            $optString,
            \trim($msg),
            $data ? \PHP_EOL . \json_encode($data, \JSON_UNESCAPED_SLASHES | \JSON_PRETTY_PRINT) : ''
        ));
    }
public static function log(string $msg, array $data = [], int $level = self::VERB_DEBUG, array $opts = []): void
    {
        $levelName  = self::LEVEL_NAMES[$level] ?? 'INFO';
        $colorName  = self::LEVEL2TAG[$level] ?? 'info';
        $taggedName = ColorTag::add($levelName, $colorName);

        $userOpts = [];
        foreach ($opts as $n => $v) {
            if (\is_numeric($n) || \strpos($n, '_') === 0) {
                $userOpts[] = "[$v]";
            } else {
                $userOpts[] = "[$n:$v]";
            }
        }

        $optString = $userOpts ? ' ' . \implode(' ', $userOpts) : '';

        self::write(\sprintf(
            '%s [%s]%s %s %s',
            \date('Y/m/d H:i:s'),
            $taggedName,
            $optString,
            \trim($msg),
            $data ? \PHP_EOL . \json_encode($data, \JSON_UNESCAPED_SLASHES | \JSON_PRETTY_PRINT) : ''
        ));
    }
public static function log ( string $ msg , array $ data = [ ] , int $ level = self :: VERB_DEBUG , array $ opts = [ ] ) : void { $ levelName = self :: LEVEL_NAMES [ $ level ] ?? 'INFO' ; $ colorName = self :: LEVEL2TAG [ $ level ] ?? 'info' ; $ taggedName = ColorTag :: add ( $ levelName , $ colorName ) ; $ userOpts = [ ] ; foreach ( $ opts as $ n => $ v ) { if ( \ is_numeric ( $ n ) || \ strpos ( $ n , '_' ) === 0 ) { $ userOpts [ ] = "[$v]" ; } else { $ userOpts [ ] = "[$n:$v]" ; } } $ optString = $ userOpts ? ' ' . \ implode ( ' ' , $ userOpts ) : '' ; self :: write ( \ sprintf ( '%s [%s]%s %s %s' , \ date ( 'Y/m/d H:i:s' ) , $ taggedName , $ optString , \ trim ( $ msg ) , $ data ? \ PHP_EOL . \ json_encode ( $ data , \ JSON_UNESCAPED_SLASHES | \ JSON_PRETTY_PRINT ) : '' ) ) ; }
Print log message to console
@param string $msg
@param array  $data
@param int    $level
@param array  $opts
[
'_category' => 'application',
'process' => 'work',
'pid' => 234,
'coId' => 12,
]
Print log message to console