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