Skip to content

Commit

Permalink
Merge pull request #9 from TeamControlium/#6-Set-Log-Level-Using-Strings
Browse files Browse the repository at this point in the history
Added ability to define logging level using a string.
  • Loading branch information
v-mwalk authored Oct 1, 2018
2 parents 12232d4 + b5100e5 commit a1ede6c
Show file tree
Hide file tree
Showing 2 changed files with 228 additions and 1 deletion.
198 changes: 197 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,155 @@
# Created by https://www.gitignore.io/api/osx,java,eclipse,intellij,maven

### Eclipse ###

.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath
.recommenders

# External tool builders
.externalToolBuilders/

# Locally stored "Eclipse launch configurations"
*.launch

# PyDev specific (Python IDE for Eclipse)
*.pydevproject

# CDT-specific (C/C++ Development Tooling)
.cproject

# CDT- autotools
.autotools

# Java annotation processor (APT)
.factorypath

# PDT-specific (PHP Development Tools)
.buildpath

# sbteclipse plugin
.target

# Tern plugin
.tern-project

# TeXlipse plugin
.texlipse

# STS (Spring Tool Suite)
.springBeans

# Code Recommenders
.recommenders/

# Annotation Processing
.apt_generated/

# Scala IDE specific (Scala & Java development for Eclipse)
.cache-main
.scala_dependencies
.worksheet

### Eclipse Patch ###
# Eclipse Core
.project

# JDT-specific (Eclipse Java Development Tools)
.classpath

# Annotation Processing
.apt_generated

.sts4-cache/

### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/modules.xml
# .idea/*.iml
# .idea/modules

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

### Intellij Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721

# *.iml
# modules.xml
# .idea/misc.xml
# *.ipr

# Sonarlint plugin
.idea/sonarlint

### Java ###
# Compiled class file
*.class

Expand All @@ -13,10 +165,54 @@
# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
hs_err_pid*

### Maven ###
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
.mvn/wrapper/maven-wrapper.jar

### OSX ###
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk


# End of https://www.gitignore.io/api/osx,java,eclipse,intellij,maven
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 a1ede6c

Please sign in to comment.