Skip to content

Commit

Permalink
Added ability to define logging level using a string. Error (minimum)…
Browse files Browse the repository at this point in the history
…, Test Information, Test Debug, Framework Information, Framework Debug (verbose)
  • Loading branch information
Mat Walker committed Oct 1, 2018
1 parent 8fc09f9 commit e5ebd69
Show file tree
Hide file tree
Showing 3 changed files with 136 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

141 changes: 104 additions & 37 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions src/main/java/TeamControlium/Utilities/Logger.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,37 @@ private Logger() {
private LogLevels _LoggingLevel;
static public LogLevels getLoggingLevel() { if (_Logger==null) { _Logger = new Logger(); } return _Logger._LoggingLevel;}
static public void setLoggingLevel(LogLevels loggingLevel) { if (_Logger==null) { _Logger = new Logger(); } _Logger._LoggingLevel = loggingLevel;}
static public void setLoggingLevel(String loggingLevel) {
if (loggingLevel==null || loggingLevel.isEmpty()) {
Logger.WriteLine(LogLevels.Error,"Logging level is blank or null! Defaulting to verbose!");
}
else {
switch (loggingLevel.trim().toLowerCase()) {
case "frameworkdebug":
case "verbose":
setLoggingLevel(LogLevels.FrameworkDebug);
break;
case "frameworkinformation":
case "frameworkinfo":
setLoggingLevel(LogLevels.FrameworkInformation);
break;
case "testdebug":
setLoggingLevel(LogLevels.TestDebug);
break;
case "testinformation":
case "testinfo":
setLoggingLevel(LogLevels.TestInformation);
break;
case "error":
case "minimum":
setLoggingLevel(LogLevels.Error);
break;
default:
setLoggingLevel(LogLevels.FrameworkDebug);
Logger.WriteLine(LogLevels.Error, String.format("Unknown logging level [%s]. Defaulting to verbose!", loggingLevel));
}
}
}

/// <summary>
/// Defines where log lines are written to.
Expand Down

0 comments on commit e5ebd69

Please sign in to comment.