Skip to content

Instantly share code, notes, and snippets.



Last active Dec 18, 2017
What would you like to do?
const pino = require('pino');
const config = require('config');
const logger = pino({level: config.logLevel});
exports.getLogger = function getLogger(module) {
return logger.child({ module: module });
exports.getMethodEndLogger = function getMethodEndLogger(logger, method, input) {
let startTime = process.hrtime();{method: method, input: input});
function methodEndLog(error, result) {
let timeDifference = process.hrtime(startTime);
let milliseconds = timeDifference[1] / 1000000;
if(error) {
return logger.error({method: method, input: input, error: error, responseTime: milliseconds});
}{method: method, input: input, result: result, responseTime: milliseconds});
return methodEndLog;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.