xdrm-framework/notice/log/1.0.md

67 lines
1.1 KiB
Markdown

```yaml
module: log
version: 1.0
requires:
- filedriver: 1.0
```
Overview
----
##### 1. Introduction
The `log` package allows you to manage multiple log files through simple code.
##### 2. Log format
> `timestamp | date | [tag] logmessage`
Example:
> `1481495961 | 2016-12-21 23:39:21 | [api_error] some content message`
##### 3. Log file location
Log files are located at `/build/log/log/{logfile}.php`.
Usage
----
> ### 1. Load the `Log` class
```php
<?php
...
use \log\core\Log;
```
> ### 2. Select the log file you want
```php
<?php
...
/* Selects the 'error' log file
*
* The target file is /build/log/log/error.log
*/
Log::get('error');
...
```
Note: If you do not give any argument to the `Log::get` method, it will use `default` as default.
> ### 3. log something on a specific log file (_"error"_ in this example)
```php
<?php
...
/* Logs a new entry into the log file /build/log/log/error.log */
Log::get('error')->log('some message', 'optional_tag');
...
```
Note: If the `message` argument is missing, it will be `...` by default, the tag if not set will be `default`.