Overview

Namespaces

  • None
  • Wei
    • Validator

Classes

  • Apc
  • App
  • ArrayCache
  • Asset
  • Base
  • BaseCache
  • BaseController
  • Bicache
  • Cache
  • Config
  • Cookie
  • Couchbase
  • Counter
  • Db
  • DbCache
  • E
  • Env
  • Error
  • FileCache
  • Gravatar
  • Http
  • Lock
  • Logger
  • Memcache
  • Memcached
  • MongoCache
  • Password
  • PhpError
  • PhpFileCache
  • Pinyin
  • Record
  • Redis
  • Request
  • Response
  • Router
  • SafeUrl
  • Session
  • Soap
  • T
  • Ua
  • Upload
  • Url
  • Uuid
  • Validate
  • View
  • WeChatApp
  • Wei
  • Overview
  • Namespace
  • Class

Class Logger

A logger service, which is inspired by Monolog

Wei\Base
Extended by Wei\Logger
Namespace: Wei
Author: Twin Huang twinhuang@qq.com
Link: https://github.com/Seldaek/monolog
Located at Logger.php
Methods summary
public boolean
# log( mixed $level, string $message, array $context = array() )

Logs with an arbitrary level

Logs with an arbitrary level

Parameters

$level
$message
$context

Returns

boolean
Whether the log record has been handled
protected boolean
# writeLog( string $level, string $message, array $context )

Write the log message

Write the log message

Parameters

$level
$message
$context

Returns

boolean
protected string
# formatLog( string $level, string $message, array $context = array() )

Format the log message

Format the log message

Parameters

$level
$message
$context

Returns

string
public boolean
# __invoke( mixed $level, string $message, array $context = array() )

Logs with an arbitrary level

Logs with an arbitrary level

Parameters

$level
$message
$context

Returns

boolean
public boolean
# emergency( string $message, array $context = array() )

System is unusable.

System is unusable.

Parameters

$message
$context

Returns

boolean
public boolean
# alert( string $message, array $context = array() )

Action must be taken immediately.

Action must be taken immediately.

Example: Entire website down, database unavailable, etc. This should trigger the SMS alerts and wake you up.

Parameters

$message
$context

Returns

boolean
public boolean
# critical( string $message, array $context = array() )

Critical conditions.

Critical conditions.

Example: Application component unavailable, unexpected exception.

Parameters

$message
$context

Returns

boolean
public boolean
# error( string $message, array $context = array() )

Runtime errors that do not require immediate action but should typically be logged and monitored.

Runtime errors that do not require immediate action but should typically be logged and monitored.

Parameters

$message
$context

Returns

boolean
public boolean
# warning( string $message, array $context = array() )

Exceptional occurrences that are not errors.

Exceptional occurrences that are not errors.

Example: Use of deprecated APIs, poor use of an API, undesirable things that are not necessarily wrong.

Parameters

$message
$context

Returns

boolean
public boolean
# notice( string $message, array $context = array() )

Normal but significant events.

Normal but significant events.

Parameters

$message
$context

Returns

boolean
public boolean
# info( string $message, array $context = array() )

Interesting events.

Interesting events.

Example: User logs in, SQL logs.

Parameters

$message
$context

Returns

boolean
public boolean
# debug( string $message, array $context = array() )

Detailed debug information.

Detailed debug information.

Parameters

$message
$context

Returns

boolean
public string
# getFile( )

Get log file

Get log file

Returns

string

Throws

RuntimeException
When unable to create logging directory
public Wei\Logger
# setLevel( string $level )

Set default log level

Set default log level

Parameters

$level

Returns

Wei\Logger
public Wei\Logger
# setHandledLevel( integer $handledLevel )

Set handled level

Set handled level

Parameters

$handledLevel
The handled level

Returns

Wei\Logger
public
# setContext( array|string $name, mixed $value = null )

Add one or multi item for log message

Add one or multi item for log message

Parameters

$name
$value

Returns


$this
public Wei\Logger
# clean( )

Clear up all log file

Clear up all log file

Returns

Wei\Logger
protected
# close( )

Close the file handle and reset to null

Close the file handle and reset to null

public
# __destruct( )

Destructor

Destructor

Methods inherited from Wei\Base
__call(), __construct(), __get(), getOption(), setOption()
Properties summary
protected string $namespace

The name of channel

The name of channel

# ''
protected string $level

The default level for log record which level is not specified

The default level for log record which level is not specified

# 'debug'
protected string $handledLevel

The lowest level to be handled

The lowest level to be handled

# 'debug'
protected array $levels

The log levels and priorities

The log levels and priorities

# array( 'debug' => 100, 'info' => 200, 'notice' => 250, 'warning' => 300, 'error' => 400, 'critical' => 500, 'alert' => 550, 'emergency' => 600 )
protected string $format

The format for log message

The format for log message

# "[%datetime%] %level%: %message%\n"
protected string $dateFormat

The date format for log message

The date format for log message

# 'H:i:s'
protected null|string $file

The log file name, if specify this parameter, the "dir" and "fileFormat" parameters would be ignored

The log file name, if specify this parameter, the "dir" and "fileFormat" parameters would be ignored

# null
protected string $dir

The directory to store log files

The directory to store log files

# 'log'
protected string $fileFormat

The log file name, formatted by date

The log file name, formatted by date

# 'Ymd.\l\o\g'
protected integer $fileSize

The max file size for log file, default to 128mb, set 0 to ignore this property

The max file size for log file, default to 128mb, set 0 to ignore this property

# 134217728
protected boolean $fileDetected

Whether log file's exact path has been detected, when set dir, fileFormat or fileSize options, log file should be detected again

Whether log file's exact path has been detected, when set dir, fileFormat or fileSize options, log file should be detected again

# false
protected array $context

A key-value array that append to the log message

A key-value array that append to the log message

# array()
Properties inherited from Wei\Base
$providers, $wei
Wei Framework API documentation generated by ApiGen