-
Notifications
You must be signed in to change notification settings - Fork 8
/
trail_settings.js
58 lines (46 loc) · 1.78 KB
/
trail_settings.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
Trail.Settings = {};
// Setting keys:
var KEYS = {
SHARE: 'share',
SHARE_LEVEL: 'level',
SHARE_METHOD_NAME: 'method_name',
TRANSPORTS: 'transports',
MONITOR: 'monitor',
MONITORS: 'monitors',
MONITOR_PUBLISH_NAME: 'monitor_name',
MONITOR_DEFAULT_LIMIT: 'monitor_default_limit',
MONITOR_CONSOLE: 'monitor_console',
MONITOR_CONSOLE_SHOW: 'show',
MONITOR_CONSOLE_THEME: 'theme',
MONITOR_CONSOLE_LARGE: 'large',
MONITOR_CONSOLE_WRAP: 'wrap'
};
Trail.Settings.KEYS = KEYS;
// Load settings:
var settings = {};
var clientSettings = Meteor.settings && Meteor.settings['public'] ? Meteor.settings['public'].trail : {};
if (Meteor.isClient) {
settings = clientSettings;
}
else if (Meteor.isServer) {
settings = Meteor.settings ? Meteor.settings.trail : {};
}
clientSettings = typeof clientSettings === 'object' ? clientSettings : {};
settings = typeof settings === 'object' ? settings : {};
Trail.Settings.settings = settings; // Client-side this is the same as clientSettings.
Trail.Settings.clientSettings = clientSettings;
Trail.Settings.Config = {}; // Parsed configuration settings.
// Handle transport settings:
if (settings[KEYS.TRANSPORTS] instanceof Array) {
Trail.Settings.Config.transports = settings[KEYS.TRANSPORTS];
}
else {
Trail.Settings.Config.transports = [{type: "console", options: {}}];
}
// Handle sharing settings:
if (clientSettings[KEYS.SHARE]) {
Trail.Settings.Config.share = true;
Trail.Settings.Config.shareMethodName = clientSettings[KEYS.SHARE_METHOD_NAME] || 'trail/logmessage';
var share = clientSettings[KEYS.SHARE];
Trail.Settings.Config.shareLevel = typeof share === 'object' && typeof share[KEYS.SHARE_LEVEL] === 'string' && Trail.LOG_LEVELS[share[KEYS.SHARE_LEVEL]] ? share[KEYS.SHARE_LEVEL] : null;
}