How to use the tracer.console function in tracer

To help you get started, we’ve selected a few tracer 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 baryon / tracer / example / depth.js View on Github external
}
	}
};


var obj =  {Request: 
	 [ { IsValid: [ 'True' ],
			ItemSearchRequest: 
				[ { ResponseGroup: [ 'Small', 'OfferSummary' ],
						Sort: [ 'salesrank' ],
						SearchIndex: [ 'DVD']
					}
				]
		 } ] };

var logger = require('tracer').console();
logger.log(obj);
logger.log("%s", obj);
logger.log("%t", obj);

// 2013-09-30T04:30:44.912Z  depth.js:23 (Object.) { Request: [ { IsValid: [Object], ItemSearchRequest: [Object] } ] }


var logger = require('tracer')[config.strategy](config.setting);
logger.log(obj);
// 
// 2013-09-30T04:30:44.927Z  depth.js:26 (Object.) { Request:
//    [ { IsValid: [ 'True', [length]: 1 ],
//        ItemSearchRequest:
//         [ { ResponseGroup: [ 'Small', 'OfferSummary', [length]: 2 ],
//             Sort: [ 'salesrank', [length]: 1 ],
//             SearchIndex: [ 'DVD', [length]: 1 ] },
github npr / potluck / server.js View on Github external
// Define third-party libraries
var util = require('util')
  , cluster = require('cluster')
  , express = require('express')
  , thumbs = require('connect-thumbs')
  , app = express()
  , _ = require('underscore')
  , CONF = require('config')
  , less = require('less')
  , log = require('tracer').console()
  , hbs = require('hbs');

// Potluck libraries
var asset = require('./lib/asset');

//-- Useful extension to HBS
require('./lib/handlebars-helpers.js')(hbs, __dirname + '/views/partials');

var pub_dir = CONF.app.pub_dir;
if (pub_dir[0] != '/') { pub_dir = '/' + pub_dir; } // humans are forgetful
pub_dir = __dirname + pub_dir;

/**
 * All environments
 */
app.configure(function() {
github mutantcornholio / veendor / test / setup.js View on Github external
const tracer = require('tracer');

const logger = require('@/lib/util/logger');
const progress = require('@/lib/util/progress');

progress.blockAllProgress(true);
const logLevel = process.env.DEBUG ? 1 : 6;
logger.setLogger(tracer.console({level: logLevel}));
github baryon / tracer / example / mongodb.js View on Github external
var mongo = require('mongoskin');
var db = mongo.db("127.0.0.1:27017/test?auto_reconnect");

var log_conf = {
		transport : function(data) {
			console.log(data.output);
			var loginfo = db.collection("loginfo");
			loginfo.insert( data, function(err, log) {
				if (err) {
					console.error(err);
				}
			});
		}
}

var logger = require('tracer').console(log_conf);

logger.log('hello');
logger.trace('hello', 'world');
logger.debug('hello %s',  'world', 123);
logger.info('hello %s %d',  'world', 123, {foo:'bar'});
logger.warn('hello %s %d %j', 'world', 123, {foo:'bar'});
logger.error('hello %s %d %j', 'world', 123, {foo:'bar'}, [1, 2, 3, 4], Object);

console.log('\n\n\npress ctrl-c to exit');
github baryon / tracer / example / multipleTransport.js View on Github external
(function (require) {
    var fs = require('fs');
    var logger = require('tracer').console({
        transport: [
            function (data) {
                fs.open('./file.log', 'a', parseInt('0644', 8), function (e, id) {
                    fs.write(id, data.output + "\n", null, 'utf8', function () {
                        fs.close(id, function () {
                        });
                    });
                });
            },
            function(data) {
                console.log(data.output);
            }
        ]
    });
    logger.log('hello');
    logger.trace('hello', 'world');
github selenodium / selenodium-grid / lib / log.js View on Github external
warn: chalkStyle('yellow'),
        debug: chalkStyle('blue'),
        error: chalkStyle('red')
    },
    logger = tracer.console({
        level: process.env.LOG_LEVEL || 'info',
        dateformat: 'HH:MM:ss.L',
        transport: function(data) {
            var filter = filters[data.title] || filters.info;
            console.log(filter(data));
        }
    }),

    logFile = path.join(process.cwd(), process.env.LOG_FILE || 'selenodium-grid.log'),
    logStream = fs.createWriteStream(logFile, {flags: 'a'}),
    fileLogger = tracer.console({
        level: 'debug',
        format: '{{timestamp}} <{{title}}> {{file}}:{{line}} {{message}}',
        transport: function(data) {
            try {
                logStream.write(data.output + '\n');
            } catch (err) {
                console.log('Error logging');
                console.log(err.message);
                console.trace('error logging');
            }
        }
    });

exports.info = function(e) {
    var msg = util.format.apply(null, arguments);
    logger.info(msg);
github baryon / tracer / example / stress.js View on Github external
function test_tracer_nostack() {
	//if the format don't include "method|path|line|pos|file", the speed will be up
    var log = require('tracer').console({
    	format: "{{timestamp}} <{{title}}> {{message}}",
    	transport : function(data) {}
    });
    
    console.time('test_tracer_nostack');
    stress_log(log);
    console.timeEnd('test_tracer_nostack');
}
github totorojs / totoro-server / lib / logger.js View on Github external
'use strict';

var fs = require('fs')
var path = require('path')
var tracer = require('tracer')
var colorful = require('colorful')

var methods = ['debug', 'info', 'warn', 'error']
var level = 'info'

module.exports = tracer.console({
  inspectOpt: {depth: null},
  methods: methods,
  level: 'debug',

  format: "{{title}} {{timestamp}} {{file}}:{{line}} | {{message}}",
  dateformat: 'yyyy-mm-dd HH:MM:ss',

  filters: {
    info: colorful.gray,
    warn: colorful.yellow,
    error: colorful.red
  },

  transport: function(data) {
    var title = data.title
    if (methods.indexOf(title) >= methods.indexOf(level)) {
github ShoppinPal / StockUp / worker / generate-weekly-stock-orders / aws-ebs / server.js View on Github external
var http = require('http');

var logger = require('tracer').console(); //var logger = console;

var taskId, messageId;
require('log-prefix')(function() {
    return '[taskId:'+taskId+'] [messageId:'+messageId+']';
});

http.createServer(function(req,res){

    taskId = Date.now();
    logger.debug('req.headers:', req.headers);
    messageId = req.headers['x-aws-sqsd-msgid'];

    req.on('data',function(data){
        var payload, config;
        try {
            payload = JSON.parse(data.toString());
github baryon / tracer / example / format.js View on Github external
"use strict";
var logger = require('tracer')
		.console(
				{
					format : "{{timestamp}} <{{title}}> {{message}} (in {{file}}:{{line}})",
					dateformat : "HH:MM:ss.L"
				});

logger.log('hello');
logger.trace('hello', 'world');
logger.debug('hello %s', 'world', 123);
logger.info('hello %s %d', 'world', 123, {foo : 'bar'});
logger.warn('hello %s %d %j', 'world', 123, {foo : 'bar'});
logger.error('hello %s %d %j', 'world', 123, {foo : 'bar'}, [ 1, 2, 3, 4 ], Object);


//$ node example/format.js 
//13:52:30.61  hello (in format.js:7)

tracer

A powerful and customizable logging library for node.js. support color console with timestamp, line number, method name, file name and call stack. you can set transport to file, stream, database(ex: mongodb and clouddb, simpledb). keywords: log, logger, t

MIT
Latest version published 1 year ago

Package Health Score

57 / 100
Full package analysis