日志类¶
遵循PSR3规范,并将其以静态方法实现便于调用
| 属性 | 值 |
|---|---|
| 命名空间 | fize\log |
| 类名 | Log |
| 常量: |
|---|
| 名称 | 类型 | 值 | 说明 |
|---|---|---|---|
| TYPE_INFO | string | “INFO” | |
| TYPE_ERROR | string | “ERROR” | |
| TYPE_DEBUG | string | “DEBUG” | |
| LEVEL_EMERGENCY | string | “emergency” | |
| LEVEL_ALERT | string | “alert” | |
| LEVEL_CRITICAL | string | “critical” | |
| LEVEL_ERROR | string | “error” | |
| LEVEL_WARNING | string | “warning” | |
| LEVEL_NOTICE | string | “notice” | |
| LEVEL_INFO | string | “info” | |
| LEVEL_DEBUG | string | “debug” |
| 方法: |
|---|
| 方法名 | 说明 |
|---|---|
| __construct() | 常规调用请先初始化 |
| emergency() | 系统无法使用。 |
| alert() | 必须立即采取行动。 |
| critical() | 临界条件。 |
| error() | 运行时错误不需要马上处理,但通常应该被记录和监控。 |
| warning() | 例外事件不是错误。 |
| notice() | 正常但重要的事件. |
| info() | 有趣的事件. |
| debug() | 详细的调试信息。 |
| log() | 可任意级别记录日志。 |
| getInstance() | 新建实例 |
常量¶
TYPE_INFO¶
| 修饰符: | public |
|---|---|
| 类型: | string |
| 值: | “INFO” |
TYPE_ERROR¶
| 修饰符: | public |
|---|---|
| 类型: | string |
| 值: | “ERROR” |
TYPE_DEBUG¶
| 修饰符: | public |
|---|---|
| 类型: | string |
| 值: | “DEBUG” |
LEVEL_EMERGENCY¶
| 修饰符: | public |
|---|---|
| 类型: | string |
| 值: | “emergency” |
LEVEL_ALERT¶
| 修饰符: | public |
|---|---|
| 类型: | string |
| 值: | “alert” |
LEVEL_CRITICAL¶
| 修饰符: | public |
|---|---|
| 类型: | string |
| 值: | “critical” |
LEVEL_ERROR¶
| 修饰符: | public |
|---|---|
| 类型: | string |
| 值: | “error” |
LEVEL_WARNING¶
| 修饰符: | public |
|---|---|
| 类型: | string |
| 值: | “warning” |
LEVEL_NOTICE¶
| 修饰符: | public |
|---|---|
| 类型: | string |
| 值: | “notice” |
LEVEL_INFO¶
| 修饰符: | public |
|---|---|
| 类型: | string |
| 值: | “info” |
LEVEL_DEBUG¶
| 修饰符: | public |
|---|---|
| 类型: | string |
| 值: | “debug” |
方法¶
__construct()¶
常规调用请先初始化
public function __construct (
string $handler,
array $config = []
)
| 参数: |
|
|---|
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 = []
)
| 参数: |
|
|---|
getInstance()¶
新建实例
public static function getInstance (
string $handler,
array $config = []
) : \fize\log\LogHandler
| 参数: |
|
|---|