-
Notifications
You must be signed in to change notification settings - Fork 10
/
index.js
executable file
·43 lines (31 loc) · 851 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
"use strict";
var log = require( './log.js' );
// Syslog log levels
var levels = [
'emerg',
'alert',
'crit',
'err',
'warning',
'notice',
'info',
'debug'
];
// Class for journald stuff
function Journald( defaultFields ) {
// Keep the default fields in an instance
if( typeof defaultFields != 'object' ) defaultFields = {};
this._defaultFields = defaultFields;
}
// Create logging methods
for( var l in levels ) { ( function( prio, name ) {
// The static method is available for users without the need for default fields
Journald[ name ] = function( message, fields ) {
log( prio, message, fields );
};
// And the class method includes the default fields
Journald.prototype[ name ] = function( message, fields ) {
log( prio, message, fields, this._defaultFields );
};
} )( l, levels[ l ] ); }
module.exports = Journald;