xdrm-framework/notice/log/1.0.md

67 lines
1.1 KiB
Markdown
Raw Normal View History

```yaml
module: log
version: 1.0
2017-09-09 15:56:58 +00:00
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
----
2017-09-09 15:56:58 +00:00
> ### 1. Load the `Log` class
```php
<?php
...
use \log\core\Log;
```
2017-09-09 15:56:58 +00:00
> ### 2. Select the log file you want
```php
<?php
...
2017-09-09 15:56:58 +00:00
/* Selects the 'error' log file
*
* The target file is /build/log/log/error.log
*/
Log::get('error');
...
```
2017-09-09 15:56:58 +00:00
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
...
2017-09-09 15:56:58 +00:00
/* Logs a new entry into the log file /build/log/log/error.log */
Log::get('error')->log('some message', 'optional_tag');
...
```
2017-09-09 15:56:58 +00:00
Note: If the `message` argument is missing, it will be `...` by default, the tag if not set will be `default`.