cat2log
Version:
Easy-to-user log file package
105 lines (79 loc) • 2.5 kB
Markdown
[](http://git.revolutions.network/robot/cat2log/commits/master)
[](http://git.revolutions.network/robot/cat2log/commits/master)
> cat2log is a easy-to-user and user-friendly npm package, for managing log file
```js
var cat2log = require('cat2log');
```
all cat2log function handle callback that return a boolean result:
```js
var cat2log = require('cat2log');
cat2log.all.add(TAG, STATUS, INFO, function (result) {
if (result) {
// log successfully written
} else {
// log didn't written
}
});
```
If you want to use your own status or status that is not handle please use this:
```js
var cat2log = require('cat2log');
cat2log.config.use_unknown_status = true;
```
You can also override all the status with yours, just by giving an JSON Array
```js
var cat2log = require('cat2log');
const custom_status = ['status1', 'status2', 'status3', ... ]
cat2log.config.status = custom_status;
```
Here the list of handle status:
1. Unknown
2. Resuming
3. Pause
4. Up
5. Down
6. Broken
7. Warning
8. OK
9. Connected
10. Disconnected
11. info
12. Stop
13. Start
Here the default value when you initialize cat2log
``` js
{
path_default: "../../",
path_md: "../../",
path_txt: "../../",
path_json: "../../",
name_file_default: "default.log",
name_file_md: "default.log.md",
name_file_txt: "default.log",
name_file_json: "default.log.json",
date: true,
local_time: "en-US",
use_unknown_status: false,
status: ['Unknown', 'Resuming', 'Pause', 'Up', 'Down', 'Broken', 'Warning', 'OK', 'Connected', 'Disconnected', 'info', 'Stop', 'Start']
}
```
You can override any config just by giving the name of the config and the value:
```js
var cat2log = require('cat2log');
cat2log.config.path_default = "/var/log/";
cat2log.config.name_file_default = "my-super-log-file.log";
...
```
cat2log.txt.add(TAG, STATUS, info, callback);
> this function add in 'txt', 'md', and 'json' method
cat2log.txt.add(TAG, STATUS, info, callback);
cat2log.md.add(TAG, STATUS, info, callback);
cat2log.json.add(object, callback);