日志类¶
遵循PSR3规范,并附加了静态方法调用
| 属性 | 值 |
|---|---|
| 命名空间 | fize\log |
| 类名 | Log |
| 方法: |
|---|
| 方法名 | 说明 |
|---|---|
| __construct() | 常规调用请先初始化 |
| getInstance() | 新建实例 |
| emergency() | 系统无法使用 |
| alert() | 必须立即采取行动 |
| critical() | 临界条件 |
| error() | 运行时错误 |
| warning() | 例外事件不是错误 |
| notice() | 正常但重要的事件 |
| info() | 有趣的事件 |
| debug() | 详细的调试信息 |
| log() | 可任意级别记录日志 |
方法¶
__construct()¶
常规调用请先初始化
public function __construct (
string $handler,
array $config = []
)
| 参数: |
|
|---|
getInstance()¶
新建实例
public static function getInstance (
string $handler,
array $config = []
) : \fize\log\LogHandler
| 参数: |
|
|---|
emergency()¶
系统无法使用
public static function emergency (
string $message,
array $context = []
)
| 参数: |
|
|---|
alert()¶
必须立即采取行动
public static function alert (
string $message,
array $context = []
)
| 参数: |
|
|---|
例如: 整个网站宕机了,数据库挂了,等等。 这应该发送短信通知警告你.
critical()¶
临界条件
public static function critical (
string $message,
array $context = []
)
| 参数: |
|
|---|
例如: 应用组件不可用,意外的异常。
error()¶
运行时错误
public static function error (
string $message,
array $context = []
)
| 参数: |
|
|---|
运行时错误不需要马上处理,但通常应该被记录和监控。
warning()¶
例外事件不是错误
public static function warning (
string $message,
array $context = []
)
| 参数: |
|
|---|
例如: 使用过时的API,API使用不当,不合理的东西不一定是错误。
notice()¶
正常但重要的事件
public static function notice (
string $message,
array $context = []
)
| 参数: |
|
|---|
info()¶
有趣的事件
public static function info (
string $message,
array $context = []
)
| 参数: |
|
|---|
例如: 用户登录,SQL日志。
debug()¶
详细的调试信息
public static function debug (
string $message,
array $context = []
)
| 参数: |
|
|---|
log()¶
可任意级别记录日志
public static function log (
string $level,
string $message,
array $context = []
)
| 参数: |
|
|---|