How to use tracer

Comprehensive tracer code examples:

How to use tracer.setLevel:

160
161
162
163
164
165
166
167
168
169
    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,

How to use tracer.console:

20
21
22
23
24
25
26
27
28
29
if (NODE_ENV == 'dev') {
  const stream = fs.createWriteStream(path.join(LOG_DIR, LOG_FILENAME), {
    flags: 'a',
    encoding: 'utf8',
  })
  return tracer.console({
    format,
    dateformat: 'HH:MM:ss.L',
    level: LOG_LEVEL,
    inspectOpt : {

How to use tracer.colorConsole:

3
4
5
6
7
8
9
10
11
12
* @ website http://sinn.boyagirl.com
* @ use 统一try catch处理中间件
* @ 用于捕获内部错误,输出日志信息
*/ 
const tracer = require('tracer');
const logger = tracer.colorConsole({
  level: 'error',
  format: '{{timestamp}} <{{title}}> {{file}}(#{{line}}): {{message}}',
  file: 'error.log',
  path: __dirname

How to use tracer.dailyfile:

35
36
37
38
39
40
41
42
43
44
    transport: function(data) {
      stream.write(data.rawoutput + '\n')
    }
  })
} else {
  return tracer.dailyfile({
    format,
    dateformat: 'HH:MM:ss.L',
    preprocess: function(data) {
      data.title = data.title.toUpperCase()

How to use tracer.warn:

207
208
209
210
211
212
213
214
215
216
      blockNumber++;
    }
  }
}
else {
  log.warn("GOT SOME UNEXPECTED DATA which was not handled properly!");
  log.warn("===>");
  log.warn(data);
  log.warn("<===");
  log.warn("blockNumber: " + blockNumber);

How to use tracer.trace:

52
53
54
55
56
57
58
59
60
61
  }, function(err) {
    if (err) {
      logger.error(err);
      callback(err);
    }else{
      logger.trace('remove_old_from_db end');
      callback();
    }
  });
}],

How to use tracer.info:

83
84
85
86
87
88
89
90
91
92
  }
}

io.clients(function(error, clients){
  if (error) throw error;
  log.info("There are " + clients.length + " players connected");
});

socket.on('disconnect',function(data){
  loggedInUsers[username] = null;

How to use tracer.error:

24
25
26
27
28
29
30
31
32
33
      return true;
    };
  }
}, function(err, results) {
  if (err) {
    logger.error(err);
    callback(err);
  };
  if (results.dataFile) {
    self.cleanFiles.push(results.dataFile);

How to use tracer.logs:

95
96
97
98
99
100
101
102
103
104
//                    logger.logs(retFormatAndStreamArray)//['GoSun', 'FashWeb', 'Ucloud']
//
//                    redisPromise.saddAsync(reqSid, retFormatAndStreamArray).then(function (v) {//1 # 新添加单个元素
//                        logger.logs(v)
//                    }).catch(function (e) {
//                        logger.logs(e)
//                    })
//                })
//            })
//

How to use tracer.log:

60
61
62
63
64
65
66
67
68
69
recordedWSTraffic: [],
colormap: [{ r: 0, g: 0, b: 0 }],

traceLog: function (f, l) {
  if (typeof l === 'undefined' || me.debug > l) {
    tracer.log(String(f.name) + ' ' + (f.caller ? (f.caller.name || 'annonymous') : 'root'));
  }
},
niiTag: bufferTag('nii', 8),
// const mghTag = bufferTag("mgh", 8);

How to use tracer.debug:

18
19
20
21
22
23
24
25
26
27
28
29
  devtools()
  process.env.ELECTRON_DISABLE_SECURITY_WARNINGS = 'true'
}


console.log('IS_DEV: ', process.env.IS_DEV)
// logger.debug('IS_DEV: ', process.env.IS_DEV)
// console.log("debug: ", debug)
// debug('main.js: %s %s', fn, cl().line)


if (process.env.IS_DEV) process.env.TRACER_DEBUG = 'debug'