Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
}
};
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 ] },
// 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() {
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}));
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');
(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');
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);
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');
}
'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)) {
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());
"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)