承接 kod/logger 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

kod/logger

Composer 安装命令:

composer require kod/logger

包简介

Psr 3 logger implementation

README 文档

README

Build Status

Lightweight and easy customizable logger implementation of the PSR-3 standard.

Requirements

Logger works with PHP >=7.1.

Installation

Install the latest version with composer

$ composer require kod/logger

Usage

Basic usage. Use default logger settings to log a message into 'php://stderr' in json format. Perfect for docker environment and works out of the box.

<?php
use Kod\Logger;

$log = new Logger();
$log->debug('Debug message', [
    'client_login' => 'login@domain.com',
]);

Note the context data (client_login field) is simply merged into the default data structure.

{
  "message": "Debug message",
  "level": "debug",
  "level_code": 7,
  "datetime": "2018-11-07T19:10:33.757+01:00",
  "client_login": "login@domain.com"
}

Here is a little bit more advanced setup for logging into a file. In this example we extend a default log data structure with fields that must be appended to every log. Those fields, if not overridden with context data, will have a default value.

<?php
use Kod\Logger;

$log = new Logger([
    'message' => [
        // extend default log's data
        'fields' => [
            'client_name' => '',
            'client_login' => '',
            'request_uri' => $_SERVER['REQUEST_URI'],
            'client_ip' => $_SERVER['REMOTE_ADDR'],
        ],
    ],
    // distribution channels: places where logs must be written 
    'channels' => [
        [
            'handler' => [
                'path' => '/var/tmp/debug.log'
            ],
        ],
    ],
]);

$log->debug('Debug message', [
    'client_login' => 'login@domain.com',
]);

And here is our log message:

{
    "message": "Debug message",
    "level": "debug",
    "level_code": 7,
    "datetime": "2018-11-07T19:10:33.757+01:00",
    "client_name": "",
    "client_login": "login@domain.com",
    "request_uri": "/",
    "client_ip": "127.0.0.1"
}

Documentation

About

Submitting bugs and feature requests

Bugs and feature requests are tracked on GitHub

Author

Konstantin Deryabin - kderyabin@orange.fr

License

Logger is licensed under the MIT License - see the LICENSE file for details

统计信息

  • 总下载量: 31
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 3
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-11-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固