GeezerVison is showing github.com — log cycle deps · codice/jcodec@be1c926
File treeExpand file treeCollapse file tree Open diff view settings src/main/java/org/jcodec/common/logging
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: src/main/java/org/jcodec/common/logging/BufferLogSink.java +1-3Lines changed: 1 addition & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 3 | 3 | import java.util.LinkedList; | 4 | 4 | import java.util.List; | 5 | 5 |
| 6 | | -import org.jcodec.common.logging.Logger.Message; | 7 | | - | 8 | 6 | /** | 9 | 7 | * This class is part of JCodec ( www.jcodec.org ) This software is distributed | 10 | 8 | * under FreeBSD License | | 13 | 11 | * | 14 | 12 | * @author The JCodec project | 15 | 13 | */ | 16 | | -public class BufferLogSink implements Logger.LogSink { | | 14 | +public class BufferLogSink implements LogSink { | 17 | 15 |
| 18 | 16 | private List<Message> messages; | 19 | 17 |
| |
Collapse file Copy file name to clipboard +5Lines changed: 5 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +package org.jcodec.common.logging; | | 2 | + | | 3 | +public enum LogLevel { | | 4 | + DEBUG, INFO, WARN, ERROR | | 5 | +} |
Collapse file Copy file name to clipboard +5Lines changed: 5 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +package org.jcodec.common.logging; | | 2 | + | | 3 | +public interface LogSink { | | 4 | + void postMessage(Message msg); | | 5 | +} |
Collapse file Copy file name to clipboardExpand all lines: src/main/java/org/jcodec/common/logging/Logger.java +5-56Lines changed: 5 additions & 56 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 15 | 15 | */ | 16 | 16 | public class Logger { | 17 | 17 |
| 18 | | - public static enum Level { | 19 | | - DEBUG, INFO, WARN, ERROR | 20 | | - }; | 21 | | - | 22 | | - public static class Message { | 23 | | - private Level level; | 24 | | - private String fileName; | 25 | | - private String className; | 26 | | - private int lineNumber; | 27 | | - private String message; | 28 | | - private String methodName; | 29 | | - | 30 | | - public Message(Level level, String fileName, String className, String methodName, int lineNumber, String message) { | 31 | | - this.level = level; | 32 | | - this.fileName = fileName; | 33 | | - this.className = className; | 34 | | - this.methodName = methodName; | 35 | | - this.message = methodName; | 36 | | - this.lineNumber = lineNumber; | 37 | | - this.message = message; | 38 | | - } | 39 | | - | 40 | | - public Level getLevel() { | 41 | | - return level; | 42 | | - } | 43 | | - | 44 | | - public String getFileName() { | 45 | | - return fileName; | 46 | | - } | 47 | | - | 48 | | - public String getClassName() { | 49 | | - return className; | 50 | | - } | 51 | | - | 52 | | - public String getMethodName() { | 53 | | - return methodName; | 54 | | - } | 55 | | - | 56 | | - public int getLineNumber() { | 57 | | - return lineNumber; | 58 | | - } | 59 | | - | 60 | | - public String getMessage() { | 61 | | - return message; | 62 | | - } | 63 | | - } | 64 | | - | 65 | | - public static interface LogSink { | 66 | | - void postMessage(Message msg); | 67 | | - } | 68 | | - | 69 | 18 | private static List<LogSink> stageSinks = new LinkedList<LogSink>(); | 70 | 19 | private static List<LogSink> sinks; | 71 | 20 |
| 72 | 21 | public static void debug(String message) { | 73 | | - message(Level.DEBUG, message); | | 22 | + message(LogLevel.DEBUG, message); | 74 | 23 | } | 75 | 24 |
| 76 | 25 | public static void info(String message) { | 77 | | - message(Level.INFO, message); | | 26 | + message(LogLevel.INFO, message); | 78 | 27 | } | 79 | 28 |
| 80 | 29 | public static void warn(String message) { | 81 | | - message(Level.WARN, message); | | 30 | + message(LogLevel.WARN, message); | 82 | 31 | } | 83 | 32 |
| 84 | 33 | public static void error(String message) { | 85 | | - message(Level.ERROR, message); | | 34 | + message(LogLevel.ERROR, message); | 86 | 35 | } | 87 | 36 |
| 88 | | - private static void message(Level level, String message) { | | 37 | + private static void message(LogLevel level, String message) { | 89 | 38 | if (sinks == null) { | 90 | 39 | synchronized (Logger.class) { | 91 | 40 | if (sinks == null) { | |
Collapse file Copy file name to clipboard +44Lines changed: 44 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +package org.jcodec.common.logging; | | 2 | + | | 3 | +public class Message { | | 4 | + private LogLevel level; | | 5 | + private String fileName; | | 6 | + private String className; | | 7 | + private int lineNumber; | | 8 | + private String message; | | 9 | + private String methodName; | | 10 | + | | 11 | + public Message(LogLevel level, String fileName, String className, String methodName, int lineNumber, String message) { | | 12 | + this.level = level; | | 13 | + this.fileName = fileName; | | 14 | + this.className = className; | | 15 | + this.methodName = methodName; | | 16 | + this.message = methodName; | | 17 | + this.lineNumber = lineNumber; | | 18 | + this.message = message; | | 19 | + } | | 20 | + | | 21 | + public LogLevel getLevel() { | | 22 | + return level; | | 23 | + } | | 24 | + | | 25 | + public String getFileName() { | | 26 | + return fileName; | | 27 | + } | | 28 | + | | 29 | + public String getClassName() { | | 30 | + return className; | | 31 | + } | | 32 | + | | 33 | + public String getMethodName() { | | 34 | + return methodName; | | 35 | + } | | 36 | + | | 37 | + public int getLineNumber() { | | 38 | + return lineNumber; | | 39 | + } | | 40 | + | | 41 | + public String getMessage() { | | 42 | + return message; | | 43 | + } | | 44 | +} |
Collapse file Copy file name to clipboardExpand all lines: src/main/java/org/jcodec/common/logging/OutLogSink.java +6-8Lines changed: 6 additions & 8 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 6 | 6 | import java.util.HashMap; | 7 | 7 | import java.util.Map; | 8 | 8 |
| 9 | | -import org.jcodec.common.logging.Logger.Level; | 10 | | -import org.jcodec.common.logging.Logger.Message; | 11 | 9 | import org.jcodec.common.tools.MainUtils; | 12 | 10 | import org.jcodec.common.tools.MainUtils.ANSIColor; | 13 | 11 |
| | 19 | 17 | * | 20 | 18 | * @author The JCodec project | 21 | 19 | */ | 22 | | -public class OutLogSink implements Logger.LogSink { | | 20 | +public class OutLogSink implements LogSink { | 23 | 21 |
| 24 | 22 | public static OutLogSink createOutLogSink() { | 25 | 23 | return new OutLogSink(System.out, DEFAULT_FORMAT); | @@ -47,12 +45,12 @@ public static interface MessageFormat { | 47 | 45 |
| 48 | 46 | public static class SimpleFormat implements MessageFormat { | 49 | 47 | private String fmt; | 50 | | - private static Map<Level, ANSIColor> colorMap = new HashMap<Logger.Level, MainUtils.ANSIColor>(); | | 48 | + private static Map<LogLevel, ANSIColor> colorMap = new HashMap<LogLevel, MainUtils.ANSIColor>(); | 51 | 49 | static { | 52 | | - colorMap.put(Level.DEBUG, ANSIColor.BROWN); | 53 | | - colorMap.put(Level.INFO, ANSIColor.GREEN); | 54 | | - colorMap.put(Level.WARN, ANSIColor.MAGENTA); | 55 | | - colorMap.put(Level.ERROR, ANSIColor.RED); | | 50 | + colorMap.put(LogLevel.DEBUG, ANSIColor.BROWN); | | 51 | + colorMap.put(LogLevel.INFO, ANSIColor.GREEN); | | 52 | + colorMap.put(LogLevel.WARN, ANSIColor.MAGENTA); | | 53 | + colorMap.put(LogLevel.ERROR, ANSIColor.RED); | 56 | 54 | }; | 57 | 55 |
| 58 | 56 | public SimpleFormat(String fmt) { | |
|