定制 innmind/log-reader 二次开发

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

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

innmind/log-reader

Composer 安装命令:

composer require innmind/log-reader

包简介

Parse log files

README 文档

README

CI codecov Type Coverage

Allow you to parse symfony and apache access logs.

BEWARE, it can take a lot of time depending on the amount of data (For a typical symfony dev.log it starts to really slow down after 10k lines)

Installation

composer require innmind/log-reader

Usage

use Innmind\LogReader\{
    Reader,
    LineParser\Monolog,
    Log,
};
use Innmind\OperatingSystem\Factory;
use Innmind\Filesystem\Name;
use Innmind\Url\Path;
use Psr\Log\LogLevel;

$os = Factory::build();

$read = Reader::of(
    Monolog::of($os->clock()),
);
$os
    ->filesystem()
    ->mount(Path::of('var/logs/'))
    ->get(Name::of('prod.log'))
    ->map(static fn($file) => $file->content())
    ->map($read)
    ->map(
        static fn($logs) => $logs
            ->filter(
                static fn($log) => $log
                    ->attribute('level')
                    ->filter(static fn($level) => $level->value() === LogLevel::CRITICAL)
                    ->match(
                        static fn() => true,
                        static fn() => false,
                    ),
            )
            ->foreach(
                static fn($log) => $log
                    ->attribute('message')
                    ->match(
                        static fn($attribute) => print($attribute->value()),
                        static fn() => print('No message found'),
                    ),
            ),
        static fn() => print('File does not exist'),
    );

The above example will print all messages that were logged at a critical level.

Note

If parsing the context or extra attributes of a monolog line fail they won't be exposed as attributes in the Log object. This behaviour is implemented to not make the whole parsing fail due to this error.

Note

If a line can't be parsed for some reason it will simply be ignored and not exposed. Again this behaviour is implemented to not make the whole parsing fail.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-05-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固