public DiskLogAdapter() { formatStrategy = CsvFormatStrategy.newBuilder().build(); }
public AndroidLogAdapter() { this.formatStrategy = PrettyFormatStrategy.newBuilder().build(); }
public static void clearLogAdapters() { printer.clearLogAdapters(); }
public static void logjson(String message) { if (DEBUG_ENABLE) { Logger.json(message); } } public static void logxml(String message) {
public static void logw(String message, Object... args) { if (DEBUG_ENABLE) { Logger.v(message, args); } } public static void logwtf(String message, Object... args) {
/** * This method is synchronized in order to avoid messy of logs' order. */ private synchronized void log(int priority, @Nullable Throwable throwable, @NonNull String msg, @Nullable Object... args) { checkNotNull(msg); String tag = getTag(); String message = createMessage(msg, args); log(priority, tag, message, throwable); }
@Override public synchronized void log(int priority, @Nullable String tag, @Nullable String message, @Nullable Throwable throwable) { if (throwable != null && message != null) { message += " : " + Utils.getStackTraceString(throwable); } if (throwable != null && message == null) { message = Utils.getStackTraceString(throwable); } if (Utils.isEmpty(message)) { message = "Empty/NULL log message"; } for (LogAdapter adapter : logAdapters) { if (adapter.isLoggable(priority, tag)) { adapter.log(priority, tag, message); } } }
@NonNull public PrettyFormatStrategy build() { if (logStrategy == null) { logStrategy = new LogcatLogStrategy(); } return new PrettyFormatStrategy(this); } }
/** * Formats the given json content and print it */ public static void json(@Nullable String json) { printer.json(json); }
/** * Formats the given xml content and print it */ public static void xml(@Nullable String xml) { printer.xml(xml); }
public static void addLogAdapter(@NonNull LogAdapter adapter) { printer.addAdapter(checkNotNull(adapter)); }
private void logChunk(int priority, @Nullable String tag, @NonNull String chunk) { checkNotNull(chunk); logStrategy.log(priority, tag, chunk); }
private CsvFormatStrategy(@NonNull Builder builder) { checkNotNull(builder); date = builder.date; dateFormat = builder.dateFormat; logStrategy = builder.logStrategy; tag = builder.tag; }
/** * Given tag will be used as tag only once for this method call regardless of the tag that's been * set during initialization. After this invocation, the general tag that's been set will * be used for the subsequent log calls */ public static Printer t(@Nullable String tag) { return printer.t(tag); }
/** * General log function that accepts all configurations as parameter */ public static void log(int priority, @Nullable String tag, @Nullable String message, @Nullable Throwable throwable) { printer.log(priority, tag, message, throwable); }
WriteHandler(@NonNull Looper looper, @NonNull String folder, int maxFileSize) { super(checkNotNull(looper)); this.folder = checkNotNull(folder); this.maxFileSize = maxFileSize; }
private PrettyFormatStrategy(@NonNull Builder builder) { checkNotNull(builder); methodCount = builder.methodCount; methodOffset = builder.methodOffset; showThreadInfo = builder.showThreadInfo; logStrategy = builder.logStrategy; tag = builder.tag; }