Skip to content

Commit b142cf8

Browse files
committed
Reader docs
1 parent d963983 commit b142cf8

File tree

2 files changed

+55
-3
lines changed

2 files changed

+55
-3
lines changed

Readme.md

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11

22
# Log.js
33

4-
Light-weight logging for [NodeJS](http://nodejs.org).
4+
Light-weight logging for [NodeJS](http://nodejs.org), including a
5+
streaming log reader.
56

67
## Installation
78

@@ -29,6 +30,32 @@ Instead of the log level constants, you may also supply a string:
2930
var Log = require('log')
3031
, log = new Log('warning');
3132

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+
3259
## Log Levels
3360

3461
Mirror that of syslog:
@@ -40,4 +67,29 @@ Instead of the log level constants, you may also supply a string:
4067
- 4 __WARNING__ warning condition
4168
- 5 __NOTICE__ a normal but significant condition
4269
- 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.

examples/reader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ var Log = require('../lib/log')
1010

1111
log.on('line', function(line){
1212
console.log(line);
13-
});;
13+
});

0 commit comments

Comments
 (0)