How to use log-driver - 10 common examples

To help you get started, we’ve selected a few log-driver examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github badges / shielded / lib / shield.js View on Github external
fs.readFile(__dirname + "/shield.svg", function(err, contents){
    if (err){ 
      return cb(err);
    }
    contents = contents.toString();
    var svgFileName = tempdir + '/' + getUniqueId(vendorText, statusText, color, 1) + '.svg';
        // scale value is irrelevant for svg, so just set it to a constant 1
    logger.debug("contents: ", contents);
    logger.debug("svg file: ", svgFileName);
    var svgFileStream = fs.createWriteStream(svgFileName);
    contents.split('||').forEach(function(piece){
      switch(piece){
        case 'vendor' : 
          piece = vendorText;
        break;
        case 'status' : 
          piece = statusText;
        break;
        case 'color' : 
          piece = color;
        break;
      }
      svgFileStream.write(piece);
    });
github badges / shielded / lib / shield.js View on Github external
fs.readFile(__dirname + "/shield.svg", function(err, contents){
    if (err){ 
      return cb(err);
    }
    contents = contents.toString();
    var svgFileName = tempdir + '/' + getUniqueId(vendorText, statusText, color, 1) + '.svg';
        // scale value is irrelevant for svg, so just set it to a constant 1
    logger.debug("contents: ", contents);
    logger.debug("svg file: ", svgFileName);
    var svgFileStream = fs.createWriteStream(svgFileName);
    contents.split('||').forEach(function(piece){
      switch(piece){
        case 'vendor' : 
          piece = vendorText;
        break;
        case 'status' : 
          piece = statusText;
        break;
        case 'color' : 
          piece = color;
        break;
      }
      svgFileStream.write(piece);
    });
    svgFileStream.end();
github badges / shielded / lib / svg2png.js View on Github external
module.exports = function svgToPng(sourceFileName, destFileName, scale, cb) {
    if (typeof scale === "function") {
        cb = scale;
        scale = 1.0;
    }

    var args = [phantomjsCmd, converterFileName, sourceFileName, destFileName, scale];
    require('log-driver').logger.debug(args);
    execFile(process.execPath, args, function (err, stdout, stderr) {
        if (err) {
            cb(err);
        } else if (stdout.length > 0) { // PhantomJS always outputs to stdout.
            cb(new Error(stdout.toString().trim()));
        } else if (stderr.length > 0) { // But hey something else might get to stderr.
            cb(new Error(stderr.toString().trim()));
        } else {
            cb(null);
        }
    });
};
github badges / shielded / lib / shield.js View on Github external
// image is from: https://github.com/olivierlacan/shields 
var svg2png = require('./svg2png');
var fs = require('fs');
var logger = require('log-driver').logger;

var getUniqueId = function(vendorText, statusText, color, scale){
  return new Buffer(JSON.stringify({vendor:vendorText,
                                    status:statusText,
                                    color:color,
                                    scale:scale}))
                .toString('base64');
};

var shield = function(options, cb){
  if (!options.vendorText || !options.statusText){
    return cb("missing required field.");
  }
  if (options.loglevel || options.loglevel === false){
    logger = require('log-driver').logger = require('log-driver')({level : options.loglevel });
  }
github cainus / percolator / lib / Percolator.js View on Github external
this.server.on500(function(context, err){
    var req = context.req;
    var res = context.res;
    logger.error("===============================");
    logger.error("Uncaught Exception");
    logger.error(err);
    logger.error(req.method, ' ', req.url);
    logger.error(err.stack);
    try {
      res.status.internalServerError();
    } catch(ex){
      logger.error("error sending 500: ", ex);
    }
  });
github cainus / percolator / lib / Percolator.js View on Github external
this.server.on500(function(context, err){
    var req = context.req;
    var res = context.res;
    logger.error("===============================");
    logger.error("Uncaught Exception");
    logger.error(err);
    logger.error(req.method, ' ', req.url);
    logger.error(err.stack);
    try {
      res.status.internalServerError();
    } catch(ex){
      logger.error("error sending 500: ", ex);
    }
  });
github cainus / percolator / lib / Percolator.js View on Github external
this.server.on500(function(context, err){
    var req = context.req;
    var res = context.res;
    logger.error("===============================");
    logger.error("Uncaught Exception");
    logger.error(err);
    logger.error(req.method, ' ', req.url);
    logger.error(err.stack);
    try {
      res.status.internalServerError();
    } catch(ex){
      logger.error("error sending 500: ", ex);
    }
  });
github cainus / percolator / lib / Percolator.js View on Github external
this.server.on500(function(context, err){
    var req = context.req;
    var res = context.res;
    logger.error("===============================");
    logger.error("Uncaught Exception");
    logger.error(err);
    logger.error(req.method, ' ', req.url);
    logger.error(err.stack);
    try {
      res.status.internalServerError();
    } catch(ex){
      logger.error("error sending 500: ", ex);
    }
  });
github cainus / percolator / lib / Percolator.js View on Github external
function onStatusError (data){
  var req = data.req;
  var res = data.res;
  var uri = req.url;
  if (req.uri){
    uri = req.uri.toString();
  }
  logger.error(req.method, uri, res.statusCode, data.message, data.detail);
}
github cainus / percolator / lib / Percolator.js View on Github external
this.server.on500(function(context, err){
    var req = context.req;
    var res = context.res;
    logger.error("===============================");
    logger.error("Uncaught Exception");
    logger.error(err);
    logger.error(req.method, ' ', req.url);
    logger.error(err.stack);
    try {
      res.status.internalServerError();
    } catch(ex){
      logger.error("error sending 500: ", ex);
    }
  });

log-driver

log-driver is a simple logging framework for logging to stdout

ISC
Latest version published 7 years ago

Package Health Score

62 / 100
Full package analysis