@playo/logger
v0.9.24
Published
logger for playo
Downloads
422
Readme
Playo-logger
It will create logs winston according to services
It will delete logs before 30 days
PASS SERVER=production
to skip debug logs
Log Levels
- alert (Highest Priority)
- error
- info
- debug
How to use
Basic Logger create one logger file and add
const PlayoLogger = require("@playo/logger"); const Logger = new PlayoLogger("<service-name>"); module.exports = Logger;
It will create
<service-name>-YYYY-MM-DD-info
,<service-name>-YYYY-MM-DD-error
,<service-name>-YYYY-MM-DD-debug
file in/var/log/playo
folderStore Logs in Different Path
const PlayoLogger = require("@playo/logger"); const Logger = new PlayoLogger("<service-name>", "<path-name>"); module.exports = Logger;
It will create
<service-name>-YYYY-MM-DD-info
,<service-name>-YYYY-MM-DD-error
,<service-name>-YYYY-MM-DD-debug
file in<path-name>
folderMail Logger
const PlayoLogger = require("@playo/logger"); const Logger = new PlayoLogger("<service-name>"); Logger.setMailer({ 'receiverEmail': ["[email protected]"], // array of recievers, mandatory 'senderEmail': "[email protected]" // address of sender, mandatory 'senderName': 'Mail Logger' // default: Mail Logger, optional 'replyEmail': '[email protected]' // default: [email protected], optional 'region': "us-east-1", // default: 'us-east-1', optional }); module.exports = Logger;
Env Variables
AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY
Slack Logger
const PlayoLogger = require("@playo/logger"); const Logger = new PlayoLogger("<service-name>"); Logger.setSlack("<channel>"); // <channel> is optional, default is 'general' module.exports = Logger;
Env Variables
SLACK_TOKEN
Custom keys
const PlayoLogger = require("@playo/logger"); const Logger = new PlayoLogger("<service-name>"); Logger.set(key, value); module.exports = Logger;
set
can be used in the file which requires the logger instance
Example with mail and slack Logger
const PlayoLogger = require("@playo/logger");
const Logger = new PlayoLogger("utils");
Logger.setSlack("server_alerts");
Logger.setMailer({
receiverEmail: ["[email protected]"], // array of recievers, mandatory
senderEmail: "[email protected]" // address of sender, mandatory
});
module.exports = Logger;
Pass Env for mail and slack logger
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
SLACK_TOKEN
How to Log
Logger.debug(id, data, message);
Logger.info(id, data, message);
Logger.error(id, data, message);
On Critical Logs, Put both error and alert log
Logger.alert(id, data, message);
Logger.error(id, data, message);