承接 instapage/php-logger 相关项目开发

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

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

instapage/php-logger

最新稳定版本:1.5.2

Composer 安装命令:

composer require instapage/php-logger

包简介

A library for standardized logs & metric format, based on monolog/monolog.

README 文档

README

CI

A library for standardized logs & metric format, based on monolog/monolog.

Installation

Add this to require section:

"instapage/php-logger": "1.5.1"

Alternatively, you can type composer require instapage/php-logger:1.5.1.

Examples

Then add following code in your application:

<?php

declare(strict_types=1);

use Instapage\Logger\Factory\LoggerFactory;
use Instapage\Metrics\Factory\MetricCollectorFactory;
use Monolog\Logger;

require_once dirname(__DIR__) . '/vendor/autoload.php';

// Preferably put these two on DI
$logger = (new LoggerFactory())->create(
    'my-service',
    Logger::DEBUG
);

$metric = (new MetricCollectorFactory())->create(
    'my-service.worker'
);

// Simple one-liner
$logger->info('User created', ['id' => 123, 'role' => 'admin']);
$metric->collect('Queue size', 42);
$metric->collect('Memory used by worker (MB)', 123.50);

Output

Each log is a single line. Multi-line here is only to improve readability. Notice how field names change for metric depending on the type of value provided.

{
    "sChannel":"my-service",
    "sType":"log",
    "sMessage":"User created",
    "iLevel":200,
    "sLevelName":"INFO",
    "oContext": {
        "iId":123,
        "sRole":"admin"
    }
}
{
    "sChannel": "my-service.worker",
    "sType": "metric",
    "sMetricName": "Queue size",
    "iValue": 42
}
{
    "sChannel": "my-service.worker",
    "sType": "metric",
    "sMetricName": "Memory used by worker (MB)",
    "fValue": 123.5
}

How to run unit tests ?

composer test

How to run linter ?

composer lint
# to automatically fix some of the most common errors
composer lint:fix

Docker fan ?

You can also use following docker commands to try the package out:

  • docker compose -f docker/docker-compose.yml up lint
  • docker compose -f docker/docker-compose.yml up lint:fix
  • docker compose -f docker/docker-compose.yml up test
  • docker compose -f docker/docker-compose.yml up example

docker compose -f docker/docker-compose.yml down will clean up nicely afterwards.

统计信息

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

GitHub 信息

  • Stars: 2
  • Watchers: 7
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: proprietary
  • 更新时间: 2023-02-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固