0.1.2 • Published 9 years ago

seastar-log v0.1.2

Weekly downloads
1
License
MIT
Repository
-
Last release
9 years ago

seastar-log

扩展node.js原生的console,主要加入了时间、调用函数、和调用文件名的属性输出

preface

  • 代码中很多地方都用到了node.js原生的console进行日志的记录,但是在进行业务跟踪和排查时,比较重要是时间等相关信息无法输出。
  • 使用其他的日志记录组件比较重,同时要更改代码,有一定的工作量
  • 使用seastar-log比较轻量级,而且不需要更改日志记录的代码

Installation

要求node的最低版本为:0.11.x

  1. 将seastar-log.js放入自己的工程目录,然后用相对路径引入
  2. 将seastar-log.js文件放入node_modules下
  3. 通过npm安装

    npm install seastar-log

Example

使用方法与node.js原生的console大致相同

初始化

在文件的入口出加入以下代码:

var seastar_console = require('seastar-log');

delete global.console;
global.console = seastar_console;

输出调用方法的文件名

文件名 : hello.js

function print(){
	console.log('the console for seastar!!!',__filename);
}
print();

显示结果 :

[2015-5-24 15:23:47] [hello.js] [print] : the console for seastar!!!

日期时间  调用方法名  要输出的日志内容

只输出日志和调用方法名

文件名 : hello.js

function print(){
	console.log('the console for seastar!!!');
}
print();

显示结果 :

[2015-5-24 15:23:47] [unkown] [print] : the console for seastar!!!

日期时间  调用方法名  要输出的日志内容

0.1.2

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago

0.0.9

9 years ago