-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from ADI10HERO/multiline-commits
fix: update breaking change footer
- Loading branch information
Showing
3 changed files
with
81 additions
and
12 deletions.
There are no files selected for viewing
This file contains 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
39 changes: 39 additions & 0 deletions
39
src/main/java/io/jenkins/plugins/conventionalcommits/utils/LogUtils.java
This file contains 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,39 @@ | ||
package io.jenkins.plugins.conventionalcommits.utils; | ||
|
||
|
||
import io.jenkins.plugins.conventionalcommits.ConventionalCommits; | ||
|
||
import java.util.logging.ConsoleHandler; | ||
import java.util.logging.Handler; | ||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
|
||
public class LogUtils { | ||
|
||
private static final Logger LOGGER = Logger.getLogger(ConventionalCommits.class.getName()); | ||
private static Handler consoleHandler = new ConsoleHandler(); | ||
|
||
private void beforeLogging(Level loggerLevel, Level consoleLevel){ | ||
LOGGER.setLevel(loggerLevel); | ||
consoleHandler.setLevel(consoleLevel); | ||
LOGGER.addHandler(consoleHandler); | ||
} | ||
|
||
private void afterLogging(Level loggerLevel, Level consoleLevel){ | ||
LOGGER.removeHandler(consoleHandler); | ||
LOGGER.setLevel(loggerLevel); | ||
consoleHandler.setLevel(consoleLevel); | ||
} | ||
|
||
public void log(Level initialLogLevel, Level initialConsoleLevel, Level requiredLogLevel, | ||
Level requiredConsoleLevel, boolean revertAfterLogging, String message) { | ||
/* | ||
revertAfterLogging (boolean): revert to initial log and console level after logging the current log string | ||
*/ | ||
|
||
beforeLogging(requiredLogLevel, requiredConsoleLevel); | ||
LOGGER.log(requiredLogLevel, message); | ||
if (revertAfterLogging) | ||
afterLogging(initialLogLevel, initialConsoleLevel); | ||
} | ||
} |
This file contains 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