Skip to content

Commit

Permalink
Add Debugging switch (#12)
Browse files Browse the repository at this point in the history
Initialize Debugging at level 10 and turn off based on preferences (fail to verbose)
  • Loading branch information
dugite-code authored Aug 16, 2018
1 parent b26d301 commit e64346e
Show file tree
Hide file tree
Showing 7 changed files with 149 additions and 123 deletions.
15 changes: 15 additions & 0 deletions scr/chrome/content/lookout.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ const LOOKOUT_WAIT_TIME = 100;

const LOOKOUT_PREF_PREFIX = "extensions.lookout.";

// Declare Debug level Globaly
var debugLevel = 10;

var lookout = {
log_msg: function lo_log_msg( msg, level ) {
if( (level == null ? 9 : level) <= debugLevel ) {
Expand Down Expand Up @@ -86,6 +89,16 @@ var lookout = {
return this.get_pref( name, "getIntPref", default_val );
},

debug_check: function lo_debug_check() {
// set debug level based on user preference
if(!this.get_bool_pref("debug_enabled")){
debugLevel = 5;
} else {
debugLevel = 10;
this.log_msg( "LookOut: debug enabled ", 5 );
}
},

basename: function lo_basename( path ) {
var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsIFile);

Expand Down Expand Up @@ -832,6 +845,7 @@ var lookout_lib = {
},

on_end_all_attachments: function () {
lookout.debug_check();
lookout.log_msg( "LookOut: Entering on_end_all_attachments()", 6 ); //MKA
//attachment parsing has finished
lookout_lib.scan_for_tnef();
Expand All @@ -856,6 +870,7 @@ var lookout_lib = {
var LookoutInitWait = 0;

function LookoutLoad () {
lookout.debug_check();
lookout.log_msg( "LookOut: Entering LookoutLoad()", 6 ); //MKA
// Make sure other global init has finished
// e.g. messageHeaderSink has been defined
Expand Down
2 changes: 2 additions & 0 deletions scr/chrome/content/options.xul
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,12 @@
<preference id="direct_to_calendar_pref" name="extensions.lookout.direct_to_calendar" type="bool"/>
<preference id="disable_filename_character_set_pref" name="extensions.lookout.disable_filename_character_set" type="bool"/>
<preference id="strict_contenttype_set_pref" name="extensions.lookout.strict_contenttype" type="bool"/>
<preference id="enable_debug_set_pref" name="extensions.lookout.debug_enabled" type="bool"/>
</preferences>
<checkbox id="attach_raw_mapi_check" preference="attach_raw_mapi_pref" label="&attach_raw_mapi_check.label;" accesskey="&attach_raw_mapi_check.accesskey;"/>
<checkbox id="direct_to_calendar_check" preference="direct_to_calendar_pref" label="&direct_to_calendar_check.label;" accesskey="&direct_to_calendar_check.accesskey;"/>
<checkbox id="disable_filename_character_set_check" preference="disable_filename_character_set_pref" label="&disable_filename_character_set_check.label;" accesskey="&disable_filename_character_set_check.accesskey;"/>
<checkbox id="strict_contenttype_set_check" preference="strict_contenttype_set_pref" label="&strict_contenttype_set_check.label;" accesskey="&strict_contenttype_set_check.accesskey;"/>
<checkbox id="enable_debug_set_check" preference="enable_debug_set_pref" label="&enable_debug.label;" accesskey="&enable_debug.accesskey;"/>
</prefpane>
</prefwindow>
Loading

0 comments on commit e64346e

Please sign in to comment.