limingxinleo / x-phalcon-logger
Phalcon Logger 工厂类
Installs: 3 248
Dependents: 1
Suggesters: 0
Security: 0
Stars: 4
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- php: >=5.6
- ext-phalcon: ^3.0
- limingxinleo/x-support-file: ^1.0
- psr/log: ^1.0
Requires (Dev)
- phpunit/phpunit: ^5.7
This package is auto-updated.
Last update: 2024-12-17 19:58:05 UTC
README
安装
composer require limingxinleo/x-phalcon-logger
使用
<?php use Xin\Phalcon\Logger\Factory; use Phalcon\Config; use Phalcon\Logger\Formatter\Line; use Xin\Phalcon\Logger\Sys; // 初始化工厂 $config = new Config([ 'application' => [ 'logDir' => __DIR__ . '/../logs/', ], ]); $factory = new Factory($config); $context = [ 'dir' => 'test' // 如果不设置子目录,则根据日期分目录 ]; // 获取单例日志实例 $logger = $factory->getLogger('info', Sys::LOG_ADAPTER_FILE, $context); // 设置格式化 $formatter = new Line("[%date%][%type%] %message%", "Y-m-d H:i:s"); $logger->setFormatter($formatter); // 写入日志 $logger->info('日志数据');