1
1
2
2
# Log.js
3
3
4
- Light-weight logging for [ NodeJS] ( http://nodejs.org ) .
4
+ Light-weight logging for [ NodeJS] ( http://nodejs.org ) , including a
5
+ streaming log reader.
5
6
6
7
## Installation
7
8
@@ -29,6 +30,32 @@ Instead of the log level constants, you may also supply a string:
29
30
var Log = require('log')
30
31
, log = new Log('warning');
31
32
33
+ ## Reader
34
+
35
+ To stream a log, simply pass a readable stream instead of a writable:
36
+
37
+ var Log = require('log')
38
+ , fs = require('fs')
39
+ , stream = fs.createReadStream(__dirname + '/file.log')
40
+ , log = new Log('debug', stream);
41
+
42
+ log.on('line', function(line){
43
+ console.log(line);
44
+ });
45
+
46
+ Example stdout:
47
+
48
+ { date: Sun, 26 Sep 2010 01:26:14 GMT
49
+ , level: 1
50
+ , levelString: 'ALERT'
51
+ , msg: 'a alert message'
52
+ }
53
+ { date: Sun, 26 Sep 2010 01:26:14 GMT
54
+ , level: 0
55
+ , levelString: 'EMERGENCY'
56
+ , msg: 'a emergency message'
57
+ }
58
+
32
59
## Log Levels
33
60
34
61
Mirror that of syslog:
@@ -40,4 +67,29 @@ Instead of the log level constants, you may also supply a string:
40
67
- 4 __ WARNING__ warning condition
41
68
- 5 __ NOTICE__ a normal but significant condition
42
69
- 6 __ INFO__ a purely informational message
43
- - 7 __ DEBUG__ messages to debug an application
70
+ - 7 __ DEBUG__ messages to debug an application
71
+
72
+ ## License
73
+
74
+ (The MIT License)
75
+
76
+ Copyright (c) 2009-2010 TJ Holowaychuk < ; tj@vision-media.ca > ;
77
+
78
+ Permission is hereby granted, free of charge, to any person obtaining
79
+ a copy of this software and associated documentation files (the
80
+ 'Software'), to deal in the Software without restriction, including
81
+ without limitation the rights to use, copy, modify, merge, publish,
82
+ distribute, sublicense, and/or sell copies of the Software, and to
83
+ permit persons to whom the Software is furnished to do so, subject to
84
+ the following conditions:
85
+
86
+ The above copyright notice and this permission notice shall be
87
+ included in all copies or substantial portions of the Software.
88
+
89
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
90
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
91
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
92
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
93
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
94
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
95
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
0 commit comments