How to use the log.prototype function in log

To help you get started, we’ve selected a few log 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 traveloka / slack-robot / test / Robot.js View on Github external
it('should listen to authenticated event from websocket', () => {
    // use stub to prevent actual call to websocket
    const robot = new Robot('token');
    const wsStartStub = sinon.stub(RtmClient.prototype, 'start');
    const wsMessageStub = sinon.stub(RtmClient.prototype, 'on');
    const loggerStub = sinon.stub(Log.prototype, 'info');

    // mock dataStore
    const botUserMock = {
      id: 5,
      name: 'slackbot'
    };
    robot._rtm.activeUserId = 5;
    robot._rtm.dataStore = {
      getUserById: sinon.stub().withArgs(robot._rtm.activeUserId).returns(botUserMock)
    };

    wsMessageStub.withArgs('authenticated').callsArg(1);

    // start to listen
    robot.start();
github Couto / groundskeeper / lib / log.js View on Github external
// this duck is not giving you the noise that you want, you've got to just
// punch that duck until it returns what you expect."

Log.SUCCESS = Log.INFO;

Log.prototype.success = function () {
    arguments[0] = ' ✔ '.green + arguments[0];
    this.log('SUCCESS', arguments);
};

Log.prototype.info = function () {
    arguments[0] = '    ➔ '.black + arguments[0];
    this.log('INFO', arguments);
};

Log.prototype.error = function () {
    arguments[0] = '   ✘ '.red + arguments[0];
    this.log('ERROR', arguments);
    throw new Error(arguments[arguments.length - 1]);
};

module.exports = new Log('error').colorful({
    SUCCESS : '\033[0;37m',
    INFO : '\033[0;37m',
    ERROR : '\033[0;37m'
});
github Couto / groundskeeper / lib / log.js View on Github external
var Log = require('log'),
    colors = require('colors');

// Duck Punch the logger
// "... if it walks like a duck and talks like a duck, it's a duck, right? So if
// this duck is not giving you the noise that you want, you've got to just
// punch that duck until it returns what you expect."

Log.SUCCESS = Log.INFO;

Log.prototype.success = function () {
    arguments[0] = ' ✔ '.green + arguments[0];
    this.log('SUCCESS', arguments);
};

Log.prototype.info = function () {
    arguments[0] = '    ➔ '.black + arguments[0];
    this.log('INFO', arguments);
};

Log.prototype.error = function () {
    arguments[0] = '   ✘ '.red + arguments[0];
    this.log('ERROR', arguments);
    throw new Error(arguments[arguments.length - 1]);
};

module.exports = new Log('error').colorful({
    SUCCESS : '\033[0;37m',
    INFO : '\033[0;37m',
    ERROR : '\033[0;37m'
});
github Couto / groundskeeper / lib / log.js View on Github external
var Log = require('log'),
    colors = require('colors');

// Duck Punch the logger
// "... if it walks like a duck and talks like a duck, it's a duck, right? So if
// this duck is not giving you the noise that you want, you've got to just
// punch that duck until it returns what you expect."

Log.SUCCESS = Log.INFO;

Log.prototype.success = function () {
    arguments[0] = ' ✔ '.green + arguments[0];
    this.log('SUCCESS', arguments);
};

Log.prototype.info = function () {
    arguments[0] = '    ➔ '.black + arguments[0];
    this.log('INFO', arguments);
};

Log.prototype.error = function () {
    arguments[0] = '   ✘ '.red + arguments[0];
    this.log('ERROR', arguments);
    throw new Error(arguments[arguments.length - 1]);
};

module.exports = new Log('error').colorful({
github Rocket1184 / qq-bot-rebown / src / httpclient.js View on Github external
'use strict';

const qs = require('querystring');
const Log = require('log');

const Axios = require('axios');
const Cookie = require('cookie');

// Extend log.js, add log type `verbose`
Log.VERBOSE = 8;
Log.prototype.verbose = function () {
    this.log('VERBOSE', arguments);
};

const log = new Log(process.env.LOG_LEVEL || 'info');

function transformHeaders(k, v) {
    if (k === 'Cookie') {
        return Cookie.parse(v);
    } else return v;
}

function logResponse(resp) {
    if (resp) {
        log.debug(`[HttpClient] ${(resp.config.method).toUpperCase()} ${resp.status} ${resp.statusText}
URL: ${resp.config.url}`);
        log.verbose(`[HttpClient]
github traveloka / slack-robot / tests / test_Robot.js View on Github external
it('should log error from slack', () => {
    const loggerStub = sinon.stub(Log.prototype, 'error');
    const error = 'Random slack error';

    slackEventStub.withArgs('error').callsArgWith(1, error);

    new Robot(SLACK_ACCESS_TOKEN);
    loggerStub.should.be.calledWith(error);
    loggerStub.restore();
  });
});
github traveloka / slack-robot / tests / test_Robot.js View on Github external
it('should store bot information after login', () => {
    const loggerStub = sinon.stub(Log.prototype, 'info');
    slackEventStub.withArgs('loggedIn').callsArgWith(1, botInfo);

    const robot = new Robot(SLACK_ACCESS_TOKEN);

    robot.id.should.be.deep.equal(botInfo.id);
    robot.name.should.be.deep.equal(botInfo.name);
    robot.mention.should.be.deep.equal(botInfo.mention);
    loggerStub.should.be.calledWith('Logged in as x-men');

    loggerStub.restore();
  });
github catz / actual_queue / logger.js View on Github external
Logger.prototype.debug = function(msg) {
  //do not print debug logs in production
  if (!this.isProd())
    Log.prototype.debug.call(this, msg); 
}