Phalcon日志记录器
注意
所有类都以前缀命名Phalcon
日志记录器\AbstractLogger
¶
-
命名空间
Phalcon\Logger
-
使用
DateTimeImmutable
DateTimeZone
Exception
Phalcon\Logger\Adapter\AdapterInterface
Phalcon\Logger\Exception
-
继承
-
实现
抽象日志记录器类
抽象日志记录器类,提供通用功能。提供了格式化程序接口和适配器接口。可以使用内置的AdapterFactory轻松创建适配器。还提供了一个LoggerFactory,允许开发人员从配置文件中创建Logger的新实例或加载它们(参见Phalcon\Config\Config对象)。
@property AdapterInterface[] $adapters @property array $excluded @property int $logLevel @property string $name @property string $timezone
常量¶
const ALERT = 2;
const CRITICAL = 1;
const CUSTOM = 8;
const DEBUG = 7;
const EMERGENCY = 0;
const ERROR = 3;
const INFO = 6;
const NOTICE = 5;
const WARNING = 4;
属性¶
/**
* The adapter stack
*
* @var AdapterInterface[]
*/
protected $adapters;
/**
* The excluded adapters for this log process
*
* @var array
*/
protected $excluded;
/**
* Minimum log level for the logger
*
* @var int
*/
protected $logLevel = 8;
/**
* @var string
*/
protected $name = ;
/**
* @var DateTimeZone
*/
protected $timezone;
方法¶
构造函数。 将适配器添加到堆栈中。对于处理我们使用FIFO 排除某些适配器。 从堆栈中返回一个适配器 返回适配器堆栈数组 返回日志级别 返回日志记录器的名称 从堆栈中移除一个适配器 设置适配器堆栈并覆盖已有的内容 设置适配器堆栈并覆盖已有的内容 将消息添加到每个处理器进行处理 将级别从字符串/单词转换为整数 返回一个包含整数到字符串转换的日志级别数组日志记录器\适配器\AbstractAdapter
¶
-
命名空间
Phalcon\Logger\Adapter
-
使用
Phalcon\Logger\Exception
Phalcon\Logger\Formatter\FormatterInterface
Phalcon\Logger\Formatter\Line
Phalcon\Logger\Item
-
继承
-
实现
AdapterInterface
类 AbstractAdapter
@property string $defaultFormatter @property FormatterInterface $formatter @property bool $inTransaction @property array $queue
属性¶
/**
* Name of the default formatter class
*
* @var string
*/
protected $defaultFormatter = Phalcon\\Logger\Formatter\\Line;
/**
* Formatter
*
* @var FormatterInterface|null
*/
protected $formatter;
/**
* Tells if there is an active transaction or not
*
* @var bool
*/
protected $inTransaction = false;
/**
* Array with messages queued in the transaction
*
* @var array
*/
protected $queue;
方法¶
析构函数清理@throws Exception
防止序列化 防止反序列化 将消息添加到队列 开始事务 提交内部事务 返回记录器当前是否处于活动事务中 在适配器中处理消息 回滚内部事务 设置消息格式化程序 返回格式化的项目日志记录器\适配器\AdapterInterface
¶
-
命名空间
Phalcon\Logger\Adapter
-
使用
Phalcon\Logger\Formatter\FormatterInterface
Phalcon\Logger\Item
-
继承
-
实现
Phalcon\Logger\AdapterInterface
Phalcon\Logger适配器的接口
方法¶
将消息添加到队列 开始事务 关闭记录器 提交内部事务 返回内部格式化程序 返回记录器当前是否处于活动事务中 在适配器中处理消息 回滚内部事务 设置消息格式化程序日志记录器\适配器\Noop¶
-
命名空间
Phalcon\Logger\Adapter
-
使用
Phalcon\Logger\Item
-
继承
AbstractAdapter
-
实现
类 Noop
@package Phalcon\Logger\Adapter
方法¶
关闭流 处理消息即写入文件日志记录器\适配器\Stream¶
-
命名空间
Phalcon\Logger\Adapter
-
使用
LogicException
Phalcon\Logger\Exception
Phalcon\Logger\Item
-
继承
AbstractAdapter
-
实现
Phalcon\Logger\Adapter\Stream
用于将日志存储在纯文本文件中的适配器
$logger = new \Phalcon\Logger\Adapter\Stream('app/logs/test.log');
$logger->log('This is a message');
$logger->log(\Phalcon\Logger::ERROR, 'This is an error');
$logger->error('This is another error');
$logger->close();
@property string $mode @property string $name @property array $options
属性¶
/**
* The file open mode. Defaults to 'ab'
*
* @var string
*/
protected $mode = ab;
/**
* Stream name
*
* @var string
*/
protected $name;
/**
* Path options
*
* @var array
*/
protected $options;
方法¶
Stream构造函数。 关闭流 流名称 处理消息即写入文件 @todo 当我们获取 traits 时将被移除日志记录器\适配器\Syslog¶
-
命名空间
Phalcon\Logger\Adapter
-
使用
LogicException
Phalcon\Logger\Item
Phalcon\Logger\Logger
-
继承
AbstractAdapter
-
实现
类 Syslog
@property string $defaultFormatter @property int $facility @property string $name @property bool $opened @property int $option
属性¶
/**
* @var int
*/
protected $facility = ;
/**
* @var string
*/
protected $name = ;
/**
* @var bool
*/
protected $opened = false;
/**
* @var int
*/
protected $option = ;
方法¶
Syslog构造函数。 关闭记录器 处理消息即写入syslog 打开系统日志连接@link https://php.net/manual/en/function.openlog.php
日志记录器\AdapterFactory¶
-
命名空间
Phalcon\Logger
-
使用
Phalcon\Factory\AbstractFactory
Phalcon\Logger\Adapter\AdapterInterface
Phalcon\Logger\Exception
-
继承
AbstractFactory
-
实现
用于创建日志记录适配器的工厂
方法¶
AdapterFactory构造函数。public function newInstance( string $name, string $fileName, array $options = [] ): AdapterInterface;
日志记录器\Enum¶
-
命名空间
Phalcon\Logger
-
使用
-
继承
-
实现
日志级别枚举常量
常量¶
const ALERT = 2;
const CRITICAL = 1;
const CUSTOM = 8;
const DEBUG = 7;
const EMERGENCY = 0;
const ERROR = 3;
const INFO = 6;
const NOTICE = 5;
const WARNING = 4;
日志记录器\Exception¶
-
命名空间
Phalcon\Logger
-
使用
-
继承
\Exception
-
实现
Phalcon\Logger\Exception
Phalcon\Logger中抛出的异常将使用此类
日志记录器\格式化程序\AbstractFormatter
¶
-
命名空间
Phalcon\Logger\Formatter
-
使用
DateTimeImmutable
Phalcon\Logger\Item
Phalcon\Support\Helper\Str\AbstractStr
-
继承
AbstractStr
-
实现
FormatterInterface
类 AbstractFormatter
属性¶
/**
* Default date format
*
* @var string
*/
protected $dateFormat = c;
/**
* @var string
*/
protected $interpolatorLeft = %;
/**
* @var string
*/
protected $interpolatorRight = %;
方法¶
返回日期格式化以供记录器使用。日志记录器\格式化程序\FormatterInterface
¶
-
命名空间
Phalcon\Logger\Formatter
-
使用
Phalcon\Logger\Item
-
继承
-
实现
Phalcon\Logger\FormatterInterface
此接口必须由Phalcon\Logger中的格式化程序实现
方法¶
应用格式到项目日志记录器\格式化程序\Json¶
-
命名空间
Phalcon\Logger\Formatter
-
使用
JsonException
Phalcon\Logger\Item
-
继承
AbstractFormatter
-
实现
使用JSON编码格式化消息
方法¶
public function __construct( string $dateFormat = string, string $interpolatorLeft = string, string $interpolatorRight = string );
日志记录器\格式化程序\Line¶
-
命名空间
Phalcon\Logger\Formatter
-
使用
Exception
Phalcon\Logger\Item
-
继承
AbstractFormatter
-
实现
类 Line
属性¶
方法¶
public function __construct( string $format = string, string $dateFormat = string, string $interpolatorLeft = string, string $interpolatorRight = string );
日志记录器\Item¶
-
命名空间
Phalcon\Logger
-
使用
DateTimeImmutable
-
继承
-
实现
Phalcon\Logger\Item
表示日志记录事务中的每个项目
@property array $context @property string $message @property int $level @property string $levelName @property DateTimeImmutable $datetime
属性¶
/**
* @var array
*/
protected $context;
/**
* @var DateTimeImmutable
*/
protected $dateTime;
/**
* @var string
*/
protected $message;
/**
* @var int
*/
protected $level;
/**
* @var string
*/
protected $levelName;
方法¶
public function __construct( string $message, string $levelName, int $level, DateTimeImmutable $dateTime, array $context = [] );
日志记录器\Logger¶
-
命名空间
Phalcon\Logger
-
使用
Exception
Phalcon\Logger\Exception
-
继承
AbstractLogger
-
实现
LoggerInterface
Phalcon日志记录器。
带有各种适配器和格式化程序的日志记录器。提供了一个格式化程序接口和适配器接口。可以使用内置的AdapterFactory轻松创建适配器。还提供了一个LoggerFactory,允许开发人员从配置文件中创建Logger的新实例或加载它们(参见Phalcon\Config\Config对象)。
方法¶
必须立即采取行动。示例:整个网站宕机,数据库不可用等。这应该触发 SMS 警报并将你叫醒。
严重条件。示例:应用程序组件不可用,意外异常。
详细的调试信息。 系统无法使用。 不需要立即处理但在通常情况下应被记录和监控的运行时错误。 有趣的事件。示例:用户登录,SQL 日志。
使用任意级别进行记录。 正常但重要的事件。 并非错误的异常情况。示例:使用已弃用的API,API使用不当,虽然不一定错误但不理想的情况。
日志\日志工厂¶
-
命名空间
Phalcon\Logger
-
使用
DateTimeZone
Phalcon\Config\ConfigInterface
Phalcon\Factory\AbstractConfigFactory
-
继承
AbstractConfigFactory
-
实现
用于创建日志对象的工厂
属性¶
方法¶
从Config对象创建实例的工厂public function newInstance( string $name, array $adapters = [], DateTimeZone $timezone = null ): Logger;
日志\日志接口
¶
-
命名空间
Phalcon\Logger
-
使用
Phalcon\Logger\Adapter\AdapterInterface
-
继承
-
实现
基于 Phalcon 的日志对象接口。
方法¶
必须立即采取行动。示例:整个网站宕机,数据库不可用等。这应该触发 SMS 警报并将你叫醒。
严重条件。示例:应用程序组件不可用,意外异常。
详细的调试信息。 系统无法使用。 不需要立即处理但在通常情况下应被记录和监控的运行时错误。 从堆栈中返回一个适配器 返回适配器堆栈数组 返回日志级别 返回日志记录器的名称 有趣的事件。示例:用户登录,SQL 日志。
使用任意级别进行记录。 正常但重要的事件。 正常但重要的事件。