Repository navigation
Expand file tree
/
Copy pathModuleConfig.cfc
More file actions
111 lines (97 loc) · 3.05 KB
/
Copy pathModuleConfig.cfc
File metadata and controls
111 lines (97 loc) · 3.05 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/**
*********************************************************************************
* Copyright Since 2005 ColdBox Framework by Luis Majano and Ortus Solutions, Corp
* www.ortussolutions.com
* ---
* Module Config.
*/
component {
// Module Properties
this.title = "rollbar";
this.author = "Ortus Solutions";
this.webURL = "https://www.ortussolutions.com";
this.description = "A module to log and send bug reports to Rollbar";
this.version = "@build.version@+@build.number@";
// If true, looks for views in the parent first, if not found, then in the module. Else vice-versa
this.viewParentLookup = true;
// If true, looks for layouts in the parent first, if not found, then in module. Else vice-versa
this.layoutParentLookup = true;
// STATIC SCRUB FIELDS
variables.SCRUB_FIELDS = [ "passwd", "password", "password_confirmation", "secret", "confirm_password", "secret_token", "APIToken", "x-api-token" ];
variables.SCRUB_HEADERS = [ "x-api-token", "Authorization" ];
/**
* Configure
*/
function configure(){
settings = {
// Rollbar token
"ServerSideToken" = "",
// Enable the Rollbar LogBox Appender Bridge
"enableLogBoxAppender" = true,
// Min/Max levels for appender
"levelMin" = "FATAL",
"levelMax" = "ERROR",
// Enable/disable error logging
"enableExceptionLogging" = true,
// Data sanitization, scrub fields and headers, replaced with * at runtime
"scrubFields" = [],
"scrubHeaders" = []
};
}
/**
* Fired when the module is registered and activated.
*/
function onLoad(){
// Incorporate defaults into settings
settings.scrubFields.addAll( SCRUB_FIELDS );
settings.scrubHeaders.addAll( SCRUB_HEADERS );
// Load the LogBox Appenders
if( settings.enableLogBoxAppender ){
loadAppenders();
}
}
/**
* Fired when the module is unregistered and unloaded
*/
function onUnload(){
}
/**
* Trap exceptions and send them to Rollbar
*/
function onException( event, interceptData, buffer ){
if( !settings.enableExceptionLogging ){
return;
}
var rollbarService = wirebox.getInstance( "RollbarService@rollbar" );
// create log body
var logBody = rollbarService.exceptionToLogBody( interceptData.exception );
rollbarService.sendToRollbar(
logBody = logBody,
level = "error"
);
}
//**************************************** PRIVATE ************************************************//
/**
* Load LogBox Appenders
*/
private function loadAppenders(){
// Get config
var logBoxConfig = controller.getLogBox().getConfig();
var rootConfig = "";
// Register tracer appender
rootConfig = logBoxConfig.getRoot();
logBoxConfig.appender(
name = "rollbar_appender",
class = "#moduleMapping#.models.RollbarAppender",
levelMin = settings.levelMin,
levelMax = settings.levelMax
);
logBoxConfig.root(
levelMin = rootConfig.levelMin,
levelMax = rootConfig.levelMax,
appenders= listAppend( rootConfig.appenders, "rollbar_appender")
);
// Store back config
controller.getLogBox().configure( logBoxConfig );
}
}