-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModuleConfig.cfc
More file actions
63 lines (56 loc) · 2.03 KB
/
Copy pathModuleConfig.cfc
File metadata and controls
63 lines (56 loc) · 2.03 KB
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
62
63
/**
* Stachebox Appender Module
*
* Registers a self-contained LogBox appender that ships log entries to a
* Stachebox instance over HTTP. See README.md for why this exists instead
* of the `logstash` + `cbelasticsearch` module stack.
*/
component {
this.title = "Single File Stachebox Appender";
this.author = "akitogo";
this.version = "1.0.0";
this.cfmapping = "singleFileStacheboxAppender";
function configure(){
settings = {
// Master switch for the appender registration
"enabled" : true,
// Stachebox log intake endpoint, e.g. https://stachebox.example.com/logstash/api/logs
"apiUrl" : "",
// Bearer token for the endpoint - leave empty if the endpoint uses IP whitelisting
"apiAuthToken" : "",
// Grouping label for this application in Stachebox
"applicationName" : server.coldfusion.productname == "Lucee" ? getApplicationSettings().name : getApplicationMetadata().name,
// Data stream name transmitted alongside each entry
"dataStream" : "logs-coldbox-logstash-appender",
// Min/max levels for the appender
"levelMin" : "FATAL",
"levelMax" : "INFO"
};
}
/**
* Fired when the module is registered and activated.
* Registers the appender on the root logger. Does no I/O — module
* activation can never block or fail on an unreachable log target.
*/
function onLoad(){
if ( !settings.enabled || !len( settings.apiUrl ) ) {
return;
}
logBox.registerAppender(
name = "stachebox_appender",
class = "#this.cfmapping#.models.StacheboxAppender",
properties = {
"apiUrl" : settings.apiUrl,
"apiAuthToken" : settings.apiAuthToken,
"applicationName" : settings.applicationName,
"dataStream" : settings.dataStream
},
levelMin = logBox.logLevels[ settings.levelMin ],
levelMax = logBox.logLevels[ settings.levelMax ]
);
var appenders = logBox.getAppendersMap( "stachebox_appender" );
logBox.getRootLogger().addAppender( appenders[ "stachebox_appender" ] );
}
function onUnload(){
}
}