Comparing version 1.5.0 to 1.5.1
# CHANGELOG | ||
## v1.5.1 | ||
* Remove debug console.log (thx chazomaticus) | ||
## v1.5.0 | ||
@@ -4,0 +8,0 @@ |
@@ -97,3 +97,2 @@ var dgram = require('dgram'); | ||
if(callback){ | ||
console.log(callback); | ||
callback(err, bytes); | ||
@@ -100,0 +99,0 @@ } |
{ | ||
"name": "ain2", | ||
"description": "Syslog logging for node.js. Continuation of ain", | ||
"version": "1.5.0", | ||
"version": "1.5.1", | ||
"main": "./index", | ||
@@ -6,0 +6,0 @@ "author": "Alexander Dorofeev <aka.spin@gmail.com>", |
@@ -31,9 +31,12 @@ # ain* | ||
var SysLogger = require('ain2'); | ||
var console = new SysLogger(); | ||
```javascript | ||
console.log('notice: %d', Date.now()); | ||
console.info('info'); | ||
console.error('error'); | ||
var SysLogger = require('ain2'); | ||
var console = new SysLogger(); | ||
console.log('notice: %d', Date.now()); | ||
console.info('info'); | ||
console.error('error'); | ||
``` | ||
After launch in `/var/log/user` you can see the following: | ||
@@ -46,2 +49,3 @@ | ||
Note: you need to ensure syslog is listening on UDP port 514 for this example to work. On Ubuntu, for example, you would need to edit ```/etc/rsyslog.conf```, add/uncomment the following lines, and ensure rsyslog is restarted: | ||
``` | ||
@@ -54,3 +58,2 @@ # provides UDP syslog reception | ||
## Singleton logger | ||
@@ -60,14 +63,20 @@ | ||
require('ain2').getInstance(); | ||
```javascript | ||
require('ain2').getInstance(); | ||
``` | ||
If you use this, please be beware of this: | ||
require('ain2').getInstance() === require('ain2').getInstance(); | ||
=> true | ||
```javascript | ||
require('ain2').getInstance() === require('ain2').getInstance(); | ||
=> true | ||
``` | ||
As opposed to: | ||
var SysLogger = require('ain2'); | ||
new SysLogger() === new SysLogger(); | ||
=> false | ||
```javascript | ||
var SysLogger = require('ain2'); | ||
new SysLogger() === new SysLogger(); | ||
=> false | ||
``` | ||
@@ -87,7 +96,10 @@ ## Changing destinations | ||
var SysLogger = require('ain2'); | ||
var logger = new SysLogger({tag: 'node-test-app', facility: 'daemon', hostname: 'devhost', port: 3000}); | ||
logger.warn('some warning'); | ||
```javascript | ||
var SysLogger = require('ain2'); | ||
var logger = new SysLogger({tag: 'node-test-app', facility: 'daemon', hostname: 'devhost', port: 3000}); | ||
logger.warn('some warning'); | ||
``` | ||
... and in `/var/log/daemon.log`: | ||
@@ -155,32 +167,39 @@ | ||
var SysLogger = require('ain2'); | ||
var console = new SysLogger(); | ||
console.info('info', function(err, bytes){ | ||
// callback received | ||
}); | ||
console.log('notice: %d', Date.now(), function(err, bytes){ | ||
// callback received | ||
}); | ||
```javascript | ||
var SysLogger = require('ain2'); | ||
var console = new SysLogger(); | ||
console.info('info', function(err, bytes){ | ||
// callback received | ||
}); | ||
console.log('notice: %d', Date.now(), function(err, bytes){ | ||
// callback received | ||
}); | ||
``` | ||
## Custom message composer | ||
var SysLogger = require('ain2'); | ||
var console = new SysLogger(); | ||
console.setMessageComposer(function(message, severity){ | ||
return new Buffer('<' + (this.facility * 8 + severity) + '>' + | ||
this.getDate() + ' ' + '[' + process.pid + ']:' + message); | ||
}); | ||
```javascript | ||
var SysLogger = require('ain2'); | ||
var console = new SysLogger(); | ||
console.setMessageComposer(function(message, severity){ | ||
return new Buffer('<' + (this.facility * 8 + severity) + '>' + | ||
this.getDate() + ' ' + '[' + process.pid + ']:' + message); | ||
}); | ||
``` | ||
//The default implementation looks this: | ||
The default implementation looks this: | ||
SysLogger.prototype.composeSyslogMessage = function(message, severity) { | ||
return new Buffer('<' + (this.facility * 8 + severity) + '>' + | ||
this.getDate() + ' ' + this.hostname + ' ' + | ||
this.tag + '[' + process.pid + ']:' + message); | ||
} | ||
```javascript | ||
SysLogger.prototype.composeSyslogMessage = function(message, severity) { | ||
return new Buffer('<' + (this.facility * 8 + severity) + '>' + | ||
this.getDate() + ' ' + this.hostname + ' ' + | ||
this.tag + '[' + process.pid + ']:' + message); | ||
} | ||
``` | ||
@@ -217,3 +236,5 @@ ## Logging | ||
logger.send('message', 'alert'); | ||
```javascript | ||
logger.send('message', 'alert'); | ||
``` | ||
@@ -220,0 +241,0 @@ The `send` function takes two arguments: message and optional severity level. By |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34625
241
759