-
Notifications
You must be signed in to change notification settings - Fork 15
Feature/simple logging #121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
0aa366c
Add simple and basic logging
pesse 606aacb
Add some useful information to output
pesse 9e572bd
StringBlock Formatter for nicer log output
pesse 9014771
AppendLine-function
pesse 078b727
Add useful information in RunCommand
pesse 8bdaf0f
Add quiet and debug flags and also a simple debug configuration
pesse 6a7d650
Refactoring
pesse 801484f
Update documentation
pesse 36ac26e
Reporters- and VersionInfo-Command should not log atm
pesse 00c712a
Update src/main/java/org/utplsql/cli/LoggerConfiguration.java
Pazus 053dfc9
Refactoring according to Pazus suggestions
pesse 351c76a
Some more information around used connector and NLS
pesse 0733e11
Separate username/PW from connectstring so it's properly masked in lo…
pesse 2578f8a
Reporters Command should abort when no connection is possible
pesse File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package org.utplsql.cli; | ||
|
||
import ch.qos.logback.classic.Level; | ||
import ch.qos.logback.classic.Logger; | ||
import ch.qos.logback.classic.LoggerContext; | ||
import ch.qos.logback.classic.encoder.PatternLayoutEncoder; | ||
import ch.qos.logback.classic.spi.ILoggingEvent; | ||
import ch.qos.logback.core.ConsoleAppender; | ||
import com.zaxxer.hikari.HikariDataSource; | ||
import org.slf4j.LoggerFactory; | ||
|
||
class LoggerConfiguration { | ||
|
||
pesse marked this conversation as resolved.
Show resolved
Hide resolved
|
||
public enum ConfigLevel { | ||
BASIC, NONE, DEBUG | ||
} | ||
|
||
private LoggerConfiguration() { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
static void configure(ConfigLevel level) { | ||
switch ( level ) { | ||
case BASIC: | ||
configureInfo(); | ||
break; | ||
case NONE: | ||
configureSilent(); | ||
break; | ||
case DEBUG: | ||
configureDebug(); | ||
break; | ||
} | ||
} | ||
|
||
private static void configureSilent() { | ||
setRootLoggerLevel(Level.OFF); | ||
} | ||
|
||
private static void configureInfo() { | ||
setRootLoggerLevel(Level.INFO); | ||
muteHikariLogger(); | ||
setSingleConsoleAppenderWithLayout("%msg%n"); | ||
} | ||
|
||
private static void configureDebug() { | ||
setRootLoggerLevel(Level.DEBUG); | ||
setSingleConsoleAppenderWithLayout("%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n"); | ||
} | ||
|
||
private static void setRootLoggerLevel( Level level ) { | ||
Logger root = (Logger)LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); | ||
root.setLevel(level); | ||
} | ||
|
||
private static void muteHikariLogger() { | ||
((Logger) LoggerFactory.getLogger(HikariDataSource.class)).setLevel(Level.OFF); | ||
} | ||
|
||
private static void setSingleConsoleAppenderWithLayout( String patternLayout ) { | ||
Logger logger = (Logger)LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); | ||
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); | ||
|
||
PatternLayoutEncoder ple = new PatternLayoutEncoder(); | ||
ple.setPattern(patternLayout); | ||
|
||
ple.setContext(lc); | ||
ple.start(); | ||
|
||
ConsoleAppender<ILoggingEvent> consoleAppender = new ConsoleAppender<>(); | ||
consoleAppender.setEncoder(ple); | ||
consoleAppender.setContext(lc); | ||
consoleAppender.start(); | ||
|
||
logger.detachAndStopAllAppenders(); | ||
logger.setAdditive(false); | ||
logger.addAppender(consoleAppender); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.