teachiq/laravel-command-logger

记录命令及其执行时间

v2.0.1 2020-12-03 10:41 UTC

This package is auto-updated.

Last update: 2024-09-04 13:50:35 UTC


README

我们不再使用此包,而是转向使用 https://github.com/spatie/laravel-schedule-monitor 和 Oh Dear (https://ohdear.app/)。

记录命令及其执行时间

Latest Version on Packagist

记录所有命令的开始和结束,以及它们的执行时间。这对于检测计划中的命令(例如每晚)是否运行时间过长特别有用。

安装

您可以通过composer安装此包

composer require teachiq/laravel-command-logger

用法

该包会自动注册。日志默认保存到storage/logs/command.log

[2020-06-07 10:30:14] environment.DEBUG: Starting route:list at 2020-06-07 10:30:14  
[2020-06-07 10:30:14] environment.DEBUG: Finished route:list at 2020-06-07 10:30:14 (0.34346413612366 seconds)  
[2020-06-07 10:36:25] environment.DEBUG: Starting exam:move-teacher at 2020-06-09 07:36:25  
[2020-06-07 10:36:25] environment.DEBUG: __SLOW__ Finished exam:move-teacher at 2020-06-09 07:36:25 (18.763263940811 seconds)  

如果您想修改配置,可以覆盖config/command-log.php中的值。默认值如下

<?php

return [
    // The log channel where the logs are written
    'channel' => [
        'driver' => 'single',
        'path' => storage_path('logs/command.log'),
        'level' => 'debug',
    ],
    // Specify any specific commands that should be excluded from logging
    'exclude' => [
        'config:cache',
        'route:cache',
    ],
    // Exeuctions longer than this value (in seconds) will be marked with __SLOW__ in the log
    'slow' => 5,
];

测试

composer test

贡献

有关详细信息,请参阅CONTRIBUTING

安全性

如果您发现任何安全问题,请通过martin.krisell@gmail.com发送电子邮件,而不是使用问题跟踪器。

许可证

MIT许可证(MIT)。有关更多信息,请参阅许可证文件

Laravel包模板

此包是使用Laravel包模板生成的。