cat2log
v0.1.3
Published
Easy-to-user log file package
Downloads
8
Readme
cat2log
cat2log is a easy-to-user and user-friendly npm package, for managing log file
var cat2log = require('cat2log');
Callback | Return
all cat2log function handle callback that return a boolean result:
var cat2log = require('cat2log');
cat2log.all.add(TAG, STATUS, INFO, function (result) {
if (result) {
// log successfully written
} else {
// log didn't written
}
});
Available Status
If you want to use your own status or status that is not handle please use this:
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
var cat2log = require('cat2log');
const custom_status = ['status1', 'status2', 'status3', ... ]
cat2log.config.status = custom_status;
Here the list of handle status:
- Unknown
- Resuming
- Pause
- Up
- Down
- Broken
- Warning
- OK
- Connected
- Disconnected
- info
- Stop
- Start
Configuration
Here the default value when you initialize cat2log
{
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:
var cat2log = require('cat2log');
cat2log.config.path_default = "/var/log/";
cat2log.config.name_file_default = "my-super-log-file.log";
...
ALL Method
cat2log.txt.add(TAG, STATUS, info, callback);
this function add in 'txt', 'md', and 'json' method
TXT Method
cat2log.txt.add(TAG, STATUS, info, callback);
MD Method
cat2log.md.add(TAG, STATUS, info, callback);
JSON Method
cat2log.json.add(object, callback);