forked from coldbox-modules/cbox-bugloghq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ModuleConfig.cfc
139 lines (123 loc) · 4.34 KB
/
ModuleConfig.cfc
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/**
*********************************************************************************
* Copyright Since 2005 ColdBox Framework by Luis Majano and Ortus Solutions, Corp
* www.ortussolutions.com
********************************************************************************
*/
component {
// Module Properties
this.title = "bugloghq";
this.author = "Luis Majano";
this.webURL = "http://www.ortussolutions.com";
this.description = "Bug Log HQ Interaction";
this.version = "2.1.0";
// 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;
// Module Entry Point
this.entryPoint = "bugloghq";
// Auto Map Models
this.autoMapModels = false;
/**
* Configure
*/
function configure(){
// SES Routes
routes = [
// Module Entry Point
{ pattern="/", handler="test",action="index" },
// Convention Route
{ pattern="/:handler/:action?" }
];
}
/**
* Fired when the module is registered and activated.
*/
function onLoad(){
// parse parent settings
parseParentSettings();
var settings = controller.getConfigSettings().buglogHQ;
// Map service
binder.map( "BugLogService@bugloghq" )
.to( "#moduleMapping#.models.BugLogService" )
.asSingleton()
.initArg( name="bugLogListener", value=settings.bugLogListener )
.initArg( name="bugEmailRecipients", value=settings.bugEmailRecipients )
.initArg( name="bugEmailSender", value=settings.bugEmailSender )
.initArg( name="hostname", value=settings.hostname )
.initArg( name="apikey", value=settings.apikey )
.initArg( name="appName", value=settings.appName )
.initArg( name="maxDumpDepth", value=settings.maxDumpDepth )
.initArg( name="writeToCFLog", value=settings.writeToCFLog );
// Load the LogBox Appenders
if( settings.enableLogBoxAppender ){
loadAppenders();
}
}
/**
* Fired when the module is unregistered and unloaded
*/
function onUnload(){
}
/**
* Trap exceptions and send them to BugLogHQ asynchronously
*/
function onException( event, interceptData, buffer ) async{
//systemOUtput( "-----> about to send to buglog" );
wirebox.getInstance( "BugLogService@bugloghq" )
.notifyService(
message = interceptData.exception.message & "." & interceptData.exception.detail,
exception = interceptData.exception,
extraInfo = getHTTPRequestData(),
severityCode = "error"
);
//systemOUtput( "-----> sent to buglog" );
}
//**************************************** 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="bugloghq_appender", class="#moduleMapping#.models.BugLogAppender" );
logBoxConfig.root( levelMin=rootConfig.levelMin,
levelMax=rootConfig.levelMax,
appenders=listAppend( rootConfig.appenders, "bugloghq_appender") );
// Store back config
controller.getLogBox().configure( logBoxConfig );
}
/**
* parse parent settings
*/
private function parseParentSettings(){
var oConfig = controller.getSetting( "ColdBoxConfig" );
var configStruct = controller.getConfigSettings();
var bugloghq = oConfig.getPropertyMixin( "bugloghq", "variables", structnew() );
//defaults
configStruct.bugloghq = {
// The location of the listener where to send the bug reports
"bugLogListener" : "",
// A comma-delimited list of email addresses to which send the bug reports in case
"bugEmailRecipients" : "",
// The sender address to use when sending the emails mentioned above.
"bugEmailSender" : "",
// The api key in use to submit the reports, empty if none.
"apikey" : "",
// The hostname of the server you are on, leave empty for auto calculated
"hostname" : "",
// The aplication name
"appName" : "",
// The max dump depth
"maxDumpDepth" : 10,
// Write out errors to CFLog
"writeToCFLog" : true,
// Enable the BugLogHQ LogBox Appender Bridge
"enableLogBoxAppender" : false
};
// incorporate settings
structAppend( configStruct.bugloghq, bugloghq, true );
}
}