Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bookiu/monolog-timefile-handler
Another monolog handler whose filename is base on datetime.
https://github.com/bookiu/monolog-timefile-handler
logger logging monolog monolog-handler monolog-library php7
Last synced: about 2 months ago
JSON representation
Another monolog handler whose filename is base on datetime.
- Host: GitHub
- URL: https://github.com/bookiu/monolog-timefile-handler
- Owner: bookiu
- License: mit
- Created: 2019-03-11T08:55:58.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-06-28T03:58:35.000Z (over 4 years ago)
- Last Synced: 2024-10-13T13:04:20.924Z (3 months ago)
- Topics: logger, logging, monolog, monolog-handler, monolog-library, php7
- Language: PHP
- Size: 12.7 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Monolog timefile handler
# Installation
`monolog-timefile-handler` is available via composer. Just add the following code to your `composer.json` file under **required** section and execute command `composer update` or you can run:
```bash
composer require yaxin/monolog-timefile-handler
```# Usage
The handler needs some parameters:
- **\$filename**: This specify the log file name which can specify datetime within `$(datetime_format)`, and the datetime format accepted by php [date()](http://php.net/manual/en/function.date.php) function.
- **\$level**: An integer type defined by Monolog log level, default is `100` which means `DEBUG`.
- **\$bubble**: Whether the messages that are handled can bubble up the stack or not, default is `true`.
- **\$filePermission**: Optional file permissions (default (0644) are only for owner read/write).
- **\$useLocking**: Try to lock log file before doing any writes, default is `false`.
# Examples
```php
use Monolog\Logger;
use Yaxin\TimefileHandler\TimefileHandler;$logger = new Logger('app');
$handler = new TimefileHandler('/tmp/app_%(Ymd_H).log', Logger::INFO);
$logger->pushHandler($handler);
$logger->warning('This is a message');
```Then you can get the log message in `/tmp/app_.log` file.
# License
This tool is free software and is distributed under the MIT license. Please have a look at the LICENSE file for further information.