@Test public void ログレベル設定を切り替えてDcCoreLogを生成する() { final String errorMsg = "ERROR Message."; final String warningMsg = "WARNING Message."; final String infoMsg = "INFO Message."; DcCoreLog.log = new TestLogger() { @Override public void info(String msg) { assertTrue(msg.indexOf(infoMsg) > 0); } @Override public void warn(String msg) { assertTrue(msg.indexOf(warningMsg) > 0); } @Override public void error(String msg) { assertTrue(msg.indexOf(errorMsg) > 0); } }; DcCoreLog infoLog = new DcCoreLog("TEST", Severity.INFO, infoMsg); infoLog.writeLog(); DcCoreLog warningLog = new DcCoreLog("TEST", Severity.WARN, warningMsg); warningLog.writeLog(); DcCoreLog errorLog = new DcCoreLog("TEST", Severity.ERROR, errorMsg); errorLog.writeLog(); }
public void writeLog() { StackTraceElement[] ste = (new Throwable()).getStackTrace(); String logInfo = String.format("[%s] - [%s#%s:%s] - %s", this.code, ste[1].getClassName(), ste[1].getMethodName(), ste[1].getLineNumber(), this.message); switch (this.severity) { case INFO: log.info(logInfo, this.reason); break; case WARN: log.warn(logInfo, this.reason); break; case ERROR: log.error(logInfo, this.reason); break; case DEBUG: log.debug(logInfo, this.reason); break; default: log.error("Message Severity Not Defined"); } }
DcCoreLog { public void writeLog() { StackTraceElement[] ste = (new Throwable()).getStackTrace(); String logInfo = String.format("[%s] - [%s#%s:%s] - %s", this.code, ste[1].getClassName(), ste[1].getMethodName(), ste[1].getLineNumber(), this.message); switch (this.severity) { case INFO: log.info(logInfo, this.reason); break; case WARN: log.warn(logInfo, this.reason); break; case ERROR: log.error(logInfo, this.reason); break; case DEBUG: log.debug(logInfo, this.reason); break; default: log.error("Message Severity Not Defined"); } } }
DcCoreLog { public void writeLog() { StackTraceElement[] ste = (new Throwable()).getStackTrace(); String logInfo = String.format("[%s] - [%s#%s:%s] - %s", this.code, ste[1].getClassName(), ste[1].getMethodName(), ste[1].getLineNumber(), this.message); switch (this.severity) { case INFO: log.info(logInfo, this.reason); break; case WARN: log.warn(logInfo, this.reason); break; case ERROR: log.error(logInfo, this.reason); break; case DEBUG: log.debug(logInfo, this.reason); break; default: log.error("Message Severity Not Defined"); } } DcCoreLog(final String code,
            final Severity severity,
            final String message); }
DcCoreLog { public void writeLog() { StackTraceElement[] ste = (new Throwable()).getStackTrace(); String logInfo = String.format("[%s] - [%s#%s:%s] - %s", this.code, ste[1].getClassName(), ste[1].getMethodName(), ste[1].getLineNumber(), this.message); switch (this.severity) { case INFO: log.info(logInfo, this.reason); break; case WARN: log.warn(logInfo, this.reason); break; case ERROR: log.error(logInfo, this.reason); break; case DEBUG: log.debug(logInfo, this.reason); break; default: log.error("Message Severity Not Defined"); } } DcCoreLog(final String code,
            final Severity severity,
            final String message); static void loadConfig(); static DcCoreLog create(String code); String getCode(); DcCoreLog params(final Object... params); DcCoreLog reason(final Throwable t); void writeLog(); }
DcCoreLog { public void writeLog() { StackTraceElement[] ste = (new Throwable()).getStackTrace(); String logInfo = String.format("[%s] - [%s#%s:%s] - %s", this.code, ste[1].getClassName(), ste[1].getMethodName(), ste[1].getLineNumber(), this.message); switch (this.severity) { case INFO: log.info(logInfo, this.reason); break; case WARN: log.warn(logInfo, this.reason); break; case ERROR: log.error(logInfo, this.reason); break; case DEBUG: log.debug(logInfo, this.reason); break; default: log.error("Message Severity Not Defined"); } } DcCoreLog(final String code,
            final Severity severity,
            final String message); static void loadConfig(); static DcCoreLog create(String code); String getCode(); DcCoreLog params(final Object... params); DcCoreLog reason(final Throwable t); void writeLog();  }