Skip to content

Commit

Permalink
Merge pull request #90 from GrammyTraore/disableLogging
Browse files Browse the repository at this point in the history
Add possibilty to programatically disable logging before first log
  • Loading branch information
danfickle authored Apr 23, 2017
2 parents 37033fe + 7ff90d5 commit 254269a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private static String registerLoggerByName(final String loggerName) {
private static boolean initPending = true;
private static XRLogger loggerImpl;

private static boolean loggingEnabled = true;
private static Boolean loggingEnabled;

/**
* Returns a list of all loggers that will be accessed by XRLog. Each entry is a String with a logger
Expand Down Expand Up @@ -245,7 +245,9 @@ private static void init() {
return;
}

XRLog.setLoggingEnabled(Configuration.isTrue("xr.util-logging.loggingEnabled", true));
if (loggingEnabled == null) {
XRLog.setLoggingEnabled(Configuration.isTrue("xr.util-logging.loggingEnabled", true));
}

if (loggerImpl == null) {
loggerImpl = new JDKXRLogger();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.openhtmltopdf.util;

import org.junit.Assert;
import org.junit.Test;

public class XRLogTest {

@Test
public void testDisableLogBeforeFirstLog() {
XRLog.setLoggingEnabled(false);
Assert.assertFalse(XRLog.isLoggingEnabled());
XRLog.load("First log");
Assert.assertFalse(XRLog.isLoggingEnabled());
}

}

0 comments on commit 254269a

Please sign in to comment.