How to use tracer - 10 common examples

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 cloudoll / cloudoll / lib / koas / JsonValidator.js View on Github external
'use strict';

var path      = require('path');
var fs        = require('fs');
var ZSchema   = require("z-schema");
var validator = new ZSchema();
var errors    = require('../errors/errors');
var logger    = require('tracer').colorConsole();
var tools     = require('../tools');

class JsonValidator {
  constructor(schemaPath, watchDir) {
    this.schemaMap = {};
    tools.consoleLog("===========================");
    tools.consoleLog("JsonValidator 初始化开始..");
    schemaPath    = schemaPath || './schema';
    let schemaDir = path.resolve(schemaPath);
    tools.consoleLog('schema 目录:', schemaDir);


    watchDir = watchDir || ['/api/admin', '/api/open', '/api/inner'];
    watchDir.forEach(function (e) {
      e          = e.substring(e.indexOf('/', 1));
      // console.log('-----------------', e);
github luckcoding / hotchcms / server / src / utils / logger.ts View on Github external
import path from 'path'
import tracer from 'tracer'

// 日志
const dailyfile = tracer.dailyfile({
  root: path.join(__dirname, '../../logs'),
  maxLogFiles: 10,
  format: '{{timestamp}} {{message}}',
  dateformat: 'mm-dd HH:MM:ss',
})

// 打印
const colorConsole = tracer.colorConsole()

// 绑定
export default {
  log: colorConsole.log,
  trace: colorConsole.trace,
  debug: colorConsole.debug,
  info(...args: any[]) {
    colorConsole.info.apply(null, args)
    dailyfile.info.apply(null, args)
  },
  warn(...args: any[]) {
    colorConsole.warn.apply(null, args)
    dailyfile.warn.apply(null, args)
  },
  error(...args: any[]) {
    colorConsole.error.apply(null, args)
github cloudoll / cloudoll / lib / koas / mongo / BaseService.js View on Github external
'use strict';
var ObjectID    = require("mongodb").ObjectID;
var ezmongo = require('../../orm/mongo');
var logger  = require('tracer').colorConsole();

// var ZSchema   = require("z-schema");
// var validator = new ZSchema();

let Validator=require('../JsonValidator');
var errors = require('../../errors/errors');

function BaseService(table) {
  this.collection = table;
  var pathSchema  = require('path').resolve('./schema') + '/collection/' + table + '.json';

  if (process.env.debug) {
    logger.info("加载schema: " + pathSchema);
  }
  try {
    this.schema = require(pathSchema);
github mcamac / crosswords / server / sockets.js View on Github external
var passportSocketIo = require('passport.socketio');
var uuid = require('node-uuid');
var logger = require('tracer').colorConsole();
var colors = require('colors');
var logger = require('tracer').colorConsole({
    filters : [
               colors.cyan, //default filter
               //the last item can be custom filter. here is "warn" and "error" filter
               {
                 warn : colors.yellow,
                 error : [colors.red, colors.bold ]
               }
    ]
});

var R = require('ramda');

// TODO: don't hardcode
var colorScheme = [
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 luckcoding / hotchcms / server / src / utils / logger.ts View on Github external
import path from 'path'
import tracer from 'tracer'

// 日志
const dailyfile = tracer.dailyfile({
  root: path.join(__dirname, '../../logs'),
  maxLogFiles: 10,
  format: '{{timestamp}} {{message}}',
  dateformat: 'mm-dd HH:MM:ss',
})

// 打印
const colorConsole = tracer.colorConsole()

// 绑定
export default {
  log: colorConsole.log,
  trace: colorConsole.trace,
  debug: colorConsole.debug,
  info(...args: any[]) {
    colorConsole.info.apply(null, args)
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 cortexjs-legacy / cortex / filters / publish-imitate.js View on Github external
{
            dir: 'app/',
            to:  's/j/app/index'
        }
    ],
    
    build_directory: 'build/'
}

 */

var

fs = require('fs'),
tracer = require("tracer").colorConsole(),
fs_more = require('../util/fs-more'),
path = require('path'),

CONFIG_FILE = 'publish.json';
 
function PrePublish(options){
    this.cwd = options.cwd;
};


PrePublish.prototype = {
    run: function(callback){
        console.log('预打包开始...');
        
        this._getConfig();
github Nelderson / MV_Online / socket_modules / chat.js View on Github external
//Version: 0.1.2 - Added MyID call to pass client username
//Version: 0.1.1 - Cleanup of profanity filter.

var chatConfig = require('./../configurations/chat');
var config = require('./../configurations/config');
var log = require('tracer').colorConsole(config.loggingConfig);
var swearjar = require('swearjar');
var auth = require('../auth.js');

module.exports = function (sio) {
	var io = sio.of('/chat');
	io.use(auth.authSocket)

	io.on('connection', function(socket) {
		//Decoded Token
		var token = socket.user;
		var username = token.name;

		socket.emit('MyID', {name: username});

		socket.on('clientMessage',function(data) {
			if (chatConfig.profanityFilter){

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