PHP 클래스 lithium\analysis\Logger
When configuring adapters, you may specify one or more priorities for each, using the
'priority' key. This key can be a single priority level (string), or an array of multiple
levels. When a log message is written, all adpaters that are configured to accept the priority
level with which the message was written will receive the message.
{{{
Logger::config(array(
'default' => array('adapter' => 'Syslog'),
'badnews' => array(
'adapter' => 'File',
'priority' => array('emergency', 'alert', 'critical', 'error')
)
));
}}}
In the above configuration, all messages will be written to the system log (
syslogd), but only
messages with the priority
error or higher will be logged to a file. Messages can then be
written to the log(s) using the
write() method:
{{{ Logger::write('alert', 'This is an alert-level message that will be logged in 2 places'); }}}
Messages can also be written using the log priorty as a method name:
{{{ Logger::alert('This is an alert-level message that will be logged in 2 places'); }}}
This works identically to the above. The message priority levels which
Logger supports are as
follows:
emergency,
alert,
critical,
error,
warning,
notice,
info and
debug.
Attempting to use any other priority level will raise an exception. See the list of available
adapters for more information on what adapters are available, and how to configure them.
파일 보기
프로젝트 열기: unionofrad/lithium
1 사용 예제들
보호된 프로퍼티들
공개 메소드들
메소드 |
설명 |
|
__callStatic ( string $priority, array $params ) : boolean |
Acts as a proxy for the write() method, allowing log message priority names to be called as
methods, i.e.:
Logger::emergency('Something bad happened.');
This is equivalent to Logger::write('emergency', 'Something bad happened')
|
|
respondsTo ( string $method, boolean $internal = false ) : boolean |
Determines if a given method can be called. |
|
write ( string $priority, string $message, array $options = [] ) : boolean |
Writes a message to one or more log adapters, where the adapters that are written to are the
ones that respond to the given priority level. |
|
보호된 메소드들
메소드 |
설명 |
|
_configsByPriority ( string $priority, string $message, array $options = [] ) : array |
Gets the names of the adapter configurations that respond to a specific priority. The list
of adapter configurations returned will be used to write a message with the given priority. |
|
_initConfig ( string $name, array $config ) : array |
This method is called automatically to initialize the default configuration of a log adapter,
such that the adapter defaults to accepting log messages of any priority (i.e. the
'priority' key is set to true). |
|
메소드 상세
__callStatic()
공개 정적인 메소드
Acts as a proxy for the write() method, allowing log message priority names to be called as
methods, i.e.:
Logger::emergency('Something bad happened.');
This is equivalent to Logger::write('emergency', 'Something bad happened')
public static __callStatic ( string $priority, array $params ) : boolean |
$priority |
string |
The name of the method called on the `Logger` class. This should map
to a log type. |
$params |
array |
An array of parameters passed in the method. |
리턴 |
boolean |
Returns `true` or `false`, depending on the success of the `write()` method. |
_configsByPriority()
보호된 정적인 메소드
Gets the names of the adapter configurations that respond to a specific priority. The list
of adapter configurations returned will be used to write a message with the given priority.
protected static _configsByPriority ( string $priority, string $message, array $options = [] ) : array |
$priority |
string |
The priority level of a message to be written. |
$message |
string |
The message to write to the adapter. |
$options |
array |
Adapter-specific options. |
리턴 |
array |
Returns an array of names of configurations which are set up to respond to the
message priority specified in `$priority`, or configured to respond to _all_ message
priorities. |
_initConfig()
보호된 정적인 메소드
This method is called automatically to initialize the default configuration of a log adapter,
such that the adapter defaults to accepting log messages of any priority (i.e. the
'priority' key is set to true).
protected static _initConfig ( string $name, array $config ) : array |
$name |
string |
The name of the logger configuration. |
$config |
array |
The logger configuration as specified in application code. |
리턴 |
array |
Returns an array of configuration data, merged with default values. |
Determines if a given method can be called.
public static respondsTo ( string $method, boolean $internal = false ) : boolean |
$method |
string |
Name of the method. |
$internal |
boolean |
Provide `true` to perform check from inside the
class/object. When `false` checks also for public visibility;
defaults to `false`. |
리턴 |
boolean |
Returns `true` if the method can be called, `false` otherwise. |
Writes a message to one or more log adapters, where the adapters that are written to are the
ones that respond to the given priority level.
public static write ( string $priority, string $message, array $options = [] ) : boolean |
$priority |
string |
The priority of the log message to be written. |
$message |
string |
The message to be written. |
$options |
array |
An array of adapter-specific options that may be passed when writing
log messages. Some options are also handled by `Logger` itself:
- `'name'` _string_: This option can be specified if you wish to write to a
specific adapter configuration, instead of writing to the adapter(s) that
respond to the given priority. |
리턴 |
boolean |
Returns `true` if all log writes succeeded, or `false` if _any or all_ writes
failed. |
프로퍼티 상세
$_adapters 보호되어 있는 정적으로 프로퍼티
Libraries::locate() compatible path to adapters for this class.
protected static $_adapters |
$_configurations 보호되어 있는 정적으로 프로퍼티
Stores configurations for cache adapters.
protected static $_configurations |
$_priorities 보호되어 있는 정적으로 프로퍼티
An array of valid message priorities.
protected static array $_priorities |
리턴 |
array |
|