How to use the tracer.dailyfile 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 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 AschPlatform / asch / app.js View on Github external
if (program.log) {
    appConfig.logLevel = program.log
  } else if (process.env.LOG_LEVEL) {
    appConfig.logLevel = program.log
  }
  appConfig.logLevel = program.log || process.env.LOG_LEVEL || appConfig.logLevel

  if (program.daemon) {
    console.log('Asch server started as daemon ...')
    daemon({ cwd: process.cwd() })
    fs.writeFileSync(pidFile, process.pid, 'utf8')
  }

  let logger
  if (program.daemon) {
    logger = tracer.dailyfile({
      root: path.join(baseDir, 'logs'),
      maxLogFiles: 10,
      allLogsFileName: 'debug',
      dateformat: 'yyyy-mm-dd HH:MM:ss.L'
    })
  } else {
    logger = tracer.colorConsole({ dateformat: 'yyyy-mm-dd HH:MM:ss.L' })
  }
  tracer.setLevel(appConfig.logLevel)

  const options = {
    appConfig,
    genesisblock,
    logger,
    pidFile,
  }
github dtysky / BlogReworkPro / Front / server / server.bin.js View on Github external
import {Provider} from 'react-redux';
import thunkMiddleware from 'redux-thunk';
import Immutable from 'immutable';
import pug from 'pug';
import zlib from 'zlib';

import config from '../config';
import routes from '../src/routes';
import reducers from '../src/reducers';
import actionTypes from '../src/actions';

const port = config.port;
const publicPath = path.join(__dirname, '../dist');
const logPath = path.join(__dirname, '../logs');
const loggerConsole = tracer.colorConsole();
const loggerFile = tracer.dailyfile({root: logPath, maxLogFiles: 30});
const serverUrl = config.serverUrl;
const serverUrlRelToFrontServer = config.serverUrlRelToFrontServer;
const redirectTable = JSON.parse(fs.readFileSync(path.resolve(__dirname, './table.json')));

function logInfo() {
    if (config.devMode) {
        loggerConsole.info(arguments);
    }
    loggerFile.info(arguments);
}

function logError() {
    if (config.devMode) {
        loggerConsole.error(arguments);
    }
    loggerFile.error(arguments);
github baryon / tracer / example / hourlog.js View on Github external
"use strict";
var logger = require('tracer').dailyfile({root:'.', splitFormat:'yyyy-mm-dd:HH'});
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);

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);


logger.log('hello');
github baryon / tracer / example / dailyfile.js View on Github external
"use strict";
var logger = require('tracer').dailyfile({root:'.', format:" {{timestamp}} [{{title}}] ({{file}}:{{line}}) {{message}} "});

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);

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);

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