File tree Expand file tree Collapse file tree
src/main/java/pl/mjaron/tinyloki Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55 */
66public class ErrorLogMonitor implements ILogMonitor {
77
8+ @ Override
9+ public boolean isVerbose () {
10+ return false ;
11+ }
12+
13+ @ Override
14+ public void logVerbose (String what ) {
15+ }
16+
817 @ Override
918 public void logInfo (final String what ) {
10- ILogMonitor .printInfo (what );
1119 }
1220
1321 @ Override
Original file line number Diff line number Diff line change 55 */
66public interface ILogMonitor {
77
8+ /**
9+ * Default meta-logging implementation.
10+ * <p>
11+ * Used internally by TinyLoki implementation for this library diagnostic purposes.
12+ *
13+ * @param what Log content.
14+ * @since 1.1.7
15+ */
16+ static void printVerbose (final String what ) {
17+ System .out .println ("[TinyLoki][" + System .currentTimeMillis () + "][V] " + what );
18+ }
19+
820 /**
921 * Default meta-logging implementation.
1022 * <p>
@@ -27,6 +39,16 @@ static void printError(final String what) {
2739 System .err .println ("[TinyLoki][" + System .currentTimeMillis () + "][E] " + what );
2840 }
2941
42+ /**
43+ * Tells whether verbose messages are logged by this log monitor.
44+ *
45+ * @return <code>true</code> when verbose messages are processed by this log monitor.
46+ * @since 1.1.7
47+ */
48+ boolean isVerbose ();
49+
50+ void logVerbose (final String what );
51+
3052 void logInfo (final String what );
3153
3254 void logError (final String what );
Original file line number Diff line number Diff line change 66 * @since 1.0.0
77 */
88public class SilentLogMonitor implements ILogMonitor {
9+ @ Override
10+ public boolean isVerbose () {
11+ return false ;
12+ }
13+
14+ @ Override
15+ public void logVerbose (String what ) {
16+ }
17+
918 @ Override
1019 public void logInfo (String what ) {
1120 }
Original file line number Diff line number Diff line change @@ -513,11 +513,16 @@ public boolean closeSync() throws InterruptedException {
513513 protected void internalProcessLogs () throws InterruptedException {
514514 final byte [][] buffers = logCollector .collectAll ();
515515 if (buffers == null ) {
516- logMonitor .logInfo ("Buffers count: [0] (null)." );
516+ if (logMonitor .isVerbose ()) {
517+ logMonitor .logVerbose ("Buffers count: [0] (null)." );
518+ }
517519 return ;
518520 }
519521
520- logMonitor .logInfo ("Buffers count: [" + buffers .length + "]." );
522+ if (logMonitor .isVerbose ()) {
523+ logMonitor .logVerbose ("Buffers count: [" + buffers .length + "]." );
524+ }
525+
521526 for (final byte [] logs : buffers ) {
522527 final byte [] toSend ;
523528 if (logEncoder == null ) {
Original file line number Diff line number Diff line change @@ -19,6 +19,16 @@ public VerboseLogMonitor(final boolean printMessages) {
1919 this .printMessages = printMessages ;
2020 }
2121
22+ @ Override
23+ public boolean isVerbose () {
24+ return true ;
25+ }
26+
27+ @ Override
28+ public void logVerbose (String what ) {
29+ ILogMonitor .printVerbose (what );
30+ }
31+
2232 @ Override
2333 public void logInfo (String what ) {
2434 ILogMonitor .printInfo (what );
You can’t perform that action at this time.
0 commit comments