Skip to content

Instantly share code, notes, and snippets.

@pinalbhatt
Last active October 14, 2016 13:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pinalbhatt/8f69598e0fb09165bf03d305c4e67bcd to your computer and use it in GitHub Desktop.
Save pinalbhatt/8f69598e0fb09165bf03d305c4e67bcd to your computer and use it in GitHub Desktop.
SignupAPI-Logger
// Logger
// global object: Log
/**
* writes logs
* @param {String} cat - Short string for loggly filter
* @param {String} message
* @param {Object} data
* @param {Object} wwContext
* @param {string} file filename
* @returns {undefined} Nothing.
*/
Log.info(cat, message, data, wwContext, file);
Log.err(cat, message, data, wwContext, file);
Log.debug(cat, message, data, wwContext, file); // Only written if DebugLogsEnabled set to true in config files
/**
* wwContext - contains additional information for log writing
* if no data, empty object {} can be passed
* can have properties like
* market: e.g. "en-US". Default 'xx'
* logGuid: unique id of log. Default: ''
* keyValue: Default: ''
* userAgent: Default: ''
*/
// e.g.
Log.info('CoreServiceCall', 'BeforeServiceCall', reqOb, reqContext, __filename);
Log.info(ErrCodes.AppInit, 'Initiating Express', {}, {}, __filename);
// Writing Exception as Err log
const exErr = CustErr.getCustomErrFromEx(ex,ErrCodes.ExceptionDuringServicCall, __filename);
Log.err(logCat, 'Exception in Request.js::call', exErr, reqContext, __filename);
// Writing Custom Error
const svcErr = CustErr.getCustomError(ErrCodes.ErrorCallingService, 'Error Calling Service', logOb, __filename);
Log.err(this.logCat, 'AfterServiceCall-ERR', svcErr, reqContext, __filename);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment