定制 phalcon/incubator-logger 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

phalcon/incubator-logger

最新稳定版本:v2.0.0

Composer 安装命令:

composer require phalcon/incubator-logger

包简介

Phalcon Incubator Logger Adapters and Formatters

README 文档

README

Discord Packagist Version PHP from Packagist codecov Packagist

Extra Adapters for Phalcon Logger component.

Installation

composer require phalcon/incubator-logger 

Amazon CloudWatch

Adapter to store logs in AWS CloudWatch:

Note: group name and stream name must be created before call any logs. You can make it inside AWS console.

use Aws\CloudWatchLogs\CloudWatchLogsClient; use Phalcon\Incubator\Logger\Adapter\CloudWatch; use Phalcon\Logger\Logger; $di->set( 'logger', function () { $client = new CloudWatchLogsClient([ 'credentials' => [ 'key' => 'AMAZON_CLOUDWATCH_KEY', 'secret' => 'AMAZON_CLOUDWATCH_SECRET', ], 'region' => 'AMAZON_CLOUDWATCH_REGION', 'version' => 'latest', // Or any specific ]); $adapter = new CloudWatch($client, '/group/name', 'stream-name'); return new Logger('messages', ['main' => $adapter]); } );

Database

Adapter to store logs in a database table:

use Phalcon\Db\Adapter\Pdo\Mysql; use Phalcon\Incubator\Logger\Adapter\Database as DbLogger; $di->set( 'logger', function () { $connection = new Mysql( [ 'host' => 'localhost', 'username' => 'root', 'password' => 'secret', 'dbname' => 'audit', ] ); $logsName = 'errors'; $tableName = 'logs'; return new DbLogger($connection, $logsName, $tableName); } );

The following table used to store the logs:

CREATE TABLE IF NOT EXISTS `logs` ( `id` INT(10) unsigned NOT NULL AUTO_INCREMENT, `name` VARCHAR(32) DEFAULT NULL, `type` INT(3) NOT NULL, `content` text, `created_at` BIGINT unsigned NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8

UDP logger

Adapter to send messages by UDP protocol to external server

use Phalcon\Incubator\Logger\Adapter\Udp as UdpLogger; $di->set( 'logger', function () { $host = '192.168.1.2'; $port = 65000; return new UdpLogger('errors', $host, $port); } );

Slack logger

Adapter to write messages into a Slack channel

slack-log

$adapter = new \Phalcon\Incubator\Logger\Adapter\Slack('api-token','channel-name'); $logger = new \Phalcon\Logger\Logger('logger-name', ['main-slack' => $adapter]); $logger->info('Information message to log in the channel channel-name');

Creating an application in Slack API

Access this page to create an application (after choosing/creating a workspace)

Giving rights to post messages

Go to Features > OAuth & Permissions and in the Scopes section -> Add an oauth scope and select the following rights :

  • chat:write
  • chat:write.public

Get the token

You can now generate a token for your bot/user in the Install App section which looks something like this :

xoxp-1111111-22222222-33333333-aaaaaaaaaaaaaaaaaaaaaa 

统计信息

  • 总下载量: 77.84k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 9
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 9
  • Watchers: 2
  • Forks: 8
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固