All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.heavenark.infrastructure.log.Logger Maven / Gradle / Ivy

The newest version!
package com.heavenark.infrastructure.log;

import com.heavenark.infrastructure.log.component.ArkLogRunner;

import static com.heavenark.infrastructure.log.model.ArkLogType.*;

/**
 * Ark-Log main logger
* include all log type method and init
* you should create a factory to unified init logger * * @author 冰糕Luminous BGLuminous Luminous * @since 1.0.0 */ public class Logger { /** Ark Log log processor */ private final ArkLogRunner runner; /** * Constructor create a ArkLogger instance * * @param prefix log prefix if is null set tot default { MAIN }
* this param can distinguish log from project * @param completeClassName log processor target class */ protected Logger(String prefix, String completeClassName) { this.runner = new ArkLogRunner(prefix, completeClassName); } /** * INFO (this method only will use target toString()) * * @param obj log target */ public void inf(Object obj) { runner.log(INF, null, obj == null ? "null" : obj.toString()); } /** * INFO * * @param logOrFormat full log or log format, if format got some error changed to append mode, if * format got some error changed to append mode * @param objs format log fill params, same as String.format(format, objs) */ public void inf(String logOrFormat, Object... objs) { runner.log(INF, null, logOrFormat, objs); } /** * DEBUG (this method only will use target toString()) * * @param obj log target */ public void deb(Object obj) { runner.log(DEB, null, obj == null ? "null" : obj.toString()); } /** * DEBUG * * @param logOrFormat full log or log format, if format got some error changed to append mode * @param objs format log fill params, same as String.format(format, objs) */ public void deb(String logOrFormat, Object... objs) { runner.log(DEB, null, logOrFormat, objs); } /** * WARN (this method only will use target toString()) * * @param obj log target */ public void war(Object obj) { runner.log(WAR, null, obj == null ? "null" : obj.toString()); } /** * WARN * * @param logOrFormat full log or log format, if format got some error changed to append mode * @param objs format log fill params, same as String.format(format, objs) */ public void war(String logOrFormat, Object... objs) { war(null, logOrFormat, objs); } /** * WARN * * @param thr throwable class * @param logOrFormat full log or log format, if format got some error changed to append mode * @param objs format log fill params, same as String.format(format, objs) */ public void war(Throwable thr, String logOrFormat, Object... objs) { runner.log(WAR, thr, logOrFormat, objs); } /** * ERROR (this method only will use target toString()) * * @param obj log target */ public void err(Object obj) { runner.log(ERR, null, obj == null ? "null" : obj.toString()); } /** * ERROR * * @param thr throwable class */ public void err(Throwable thr) { err(thr, thr.getMessage()); } /** * ERROR * * @param logOrFormat full log or log format, if format got some error changed to append mode * @param objs format log fill params, same as String.format(format, objs) */ public void err(String logOrFormat, Object... objs) { err(null, logOrFormat, objs); } /** * ERROR * * @param thr throwable class * @param logOrFormat full log or log format, if format got some error changed to append mode * @param objs format log fill params, same as String.format(format, objs) */ public void err(Throwable thr, String logOrFormat, Object... objs) { runner.log(ERR, thr, logOrFormat, objs); } /** * FATAL * * @param thr throwable class */ public void fal(Throwable thr) { fal(thr, thr.getMessage()); } /** * FATAL (this method only will use target toString()) * * @param obj log target * @param thr throwable class */ public void fal(Throwable thr, Object obj) { runner.log(FAL, thr, obj == null ? "null" : obj.toString()); } /** * FATAL * * @param thr throwable class * @param logOrFormat full log or log format, if format got some error changed to append mode * @param objs format log fill params, same as String.format(format, objs) */ public void fal(Throwable thr, String logOrFormat, Object... objs) { runner.log(FAL, thr, logOrFormat, objs); } /** * KEY (this method only will use target toString()) * * @param obj log target */ public void key(Object obj) { runner.log(KEY, null, obj == null ? "null" : obj.toString()); } /** * KEY * * @param logOrFormat full log or log format, if format got some error changed to append mode * @param objs format log fill params, same as String.format(format, objs) */ public void key(String logOrFormat, Object... objs) { key(null, logOrFormat, objs); } /** * KEY * * @param thr throwable class * @param logOrFormat full log or log format, if format got some error changed to append mode * @param objs format log fill params, same as String.format(format, objs) */ public void key(Throwable thr, String logOrFormat, Object... objs) { runner.log(KEY, thr, logOrFormat, objs); } /** * VERBOSE (this method only will use target toString()) * * @param obj log target */ public void ver(Object obj) { runner.log(VER, null, obj == null ? "null" : obj.toString()); } /** * VERBOSE * * @param logOrFormat full log or log format, if format got some error changed to append mode * @param objs format log fill params, same as String.format(format, objs) */ public void ver(String logOrFormat, Object... objs) { ver(null, logOrFormat, objs); } /** * VERBOSE * * @param thr throwable class * @param logOrFormat full log or log format, if format got some error changed to append mode * @param objs format log fill params, same as String.format(format, objs) */ public void ver(Throwable thr, String logOrFormat, Object... objs) { runner.log(VER, thr, logOrFormat, objs); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy