forked from miktam/loggly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
logglyServer.js
61 lines (47 loc) · 1.21 KB
/
logglyServer.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
console.log('Loading winston backend for Loggly');
if (!Meteor.settings.loggly) {
console.error("Loggly not found in settings.json");
return;
}
import './imports/logglyMeteorMethods.js';
import winston from 'winston';
/**
* Basic setup of Loggly class
*/
const Loggly = function(options) {
this.client = winston;
};
/**
* Native wrapper for log method - just pass the arguments
*/
Loggly.prototype.log = function (param, tag) {
this.client.log(param, tag);
};
/**
* Set of useful methods to log with the tag
*
* @example: Loggly.warn("error message") will add tag `warn` to the `error message`
*/
Loggly.prototype._applyArguments = function (args, tag) {
if (args && args.length === 1) {
this.client.log(args[0], tag);
} else {
this.client.log(args, tag);
}
};
Loggly.prototype.trace = function () {
this._applyArguments(arguments, 'trace');
};
Loggly.prototype.info = function () {
this._applyArguments(arguments, 'info');
};
Loggly.prototype.warn = function () {
this._applyArguments(arguments, 'warn');
};
Loggly.prototype.error = function () {
this._applyArguments(arguments, 'error');
};
/**
* Logger export
*/
export default const Logger = new Loggly(Meteor.settings.loggly);