Skip to content

Teachiq/laravel-command-logger

Repository files navigation

Deprecation notice

We are no longer using this package in favor of https://github.com/spatie/laravel-schedule-monitor and Oh Dear (https://ohdear.app/).

Log commands with their execution time

Latest Version on Packagist

Log the start and finish of all commands, along with their execution time. This is especially useful to detect if scheduled commands (for instance every night) run for longer than expected.

Installation

You can install the package via composer:

composer require teachiq/laravel-command-logger

Usage

The package auto-registers. The log is saved by default to 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)  

You can configure the pagage by overriding the values in config/command-log.php if you want. The default values are the following:

<?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,
];

Testing

composer test

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

License

The MIT License (MIT). Please see License File for more information.

Laravel Package Boilerplate

This package was generated using the Laravel Package Boilerplate.

About

Log commands with their execution time

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages