X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=misc%2Fenv%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faaf%2Fmisc%2Fenv%2Fimpl%2FLog4JLogTarget.java;h=b144852a758d0dc7b8846b6b64aa87a1c8460b49;hb=7e966914050e66219689001ff4ab601a49eef0ac;hp=a5f118c9723af93b1e37e6602f2fbf68f6959fac;hpb=13df7fff629c4fae42de9c619f3bd5aeeeddf04a;p=aaf%2Fauthz.git diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/impl/Log4JLogTarget.java b/misc/env/src/main/java/org/onap/aaf/misc/env/impl/Log4JLogTarget.java index a5f118c9..b144852a 100644 --- a/misc/env/src/main/java/org/onap/aaf/misc/env/impl/Log4JLogTarget.java +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/impl/Log4JLogTarget.java @@ -37,73 +37,73 @@ import org.onap.aaf.misc.env.util.StringBuilderWriter; * */ public class Log4JLogTarget implements LogTarget { - private Level level; - private Logger log; + private Level level; + private Logger log; - public Log4JLogTarget(String loggerName, Level level) throws APIException { - this.level = level; - if (loggerName != null && loggerName.length() > 0) { - log = Logger.getLogger(loggerName); - } else { - log = Logger.getRootLogger(); - } - } + public Log4JLogTarget(String loggerName, Level level) throws APIException { + this.level = level; + if (loggerName != null && loggerName.length() > 0) { + log = Logger.getLogger(loggerName); + } else { + log = Logger.getRootLogger(); + } + } - // @Override - public boolean isLoggable() { - return log.isEnabledFor(level); - } + // @Override + public boolean isLoggable() { + return log.isEnabledFor(level); + } - // @Override - public void log(Object... msgs) { - log(null, msgs); - } + // @Override + public void log(Object... msgs) { + log(null, msgs); + } - // @Override - public void log(Throwable e, Object... msgs) { - if (log.isEnabledFor(level)) { - StringBuilder sb = new StringBuilder(); - - String msg; - if (e != null) { - e.printStackTrace(new PrintWriter(new StringBuilderWriter(sb))); - } - for (int i = 0; i < msgs.length; ++i) { - if(msgs[i]!=null) { - msg = msgs[i].toString(); - if (msg != null && msg.length() > 0) { - int sbl = sb.length(); - if (sbl > 0) { - char last = sb.charAt(sbl - 1); - if (" (.".indexOf(last) < 0 - && "().".indexOf(msg.charAt(0)) < 0) - sb.append(' '); - } - sb.append(msg); - } - } - } - log.log(level, sb.toString()); - } - } + // @Override + public void log(Throwable e, Object... msgs) { + if (log.isEnabledFor (level)) { + StringBuilder sb = new StringBuilder(); + + String msg; + if (e != null) { + e.printStackTrace(new PrintWriter(new StringBuilderWriter(sb))); + } + for (int i = 0; i < msgs.length; ++i) { + if (msgs[i]!=null) { + msg = msgs[i].toString(); + if (msg != null && msg.length() > 0) { + int sbl = sb.length(); + if (sbl > 0) { + char last = sb.charAt(sbl - 1); + if (" (.".indexOf(last) < 0 + && "().".indexOf(msg.charAt(0)) < 0) + sb.append(' '); + } + sb.append(msg); + } + } + } + log.log(level, sb.toString()); + } + } - /* (non-Javadoc) - * @see com.att.inno.env.LogTarget#printf(java.lang.String, java.lang.String[]) - */ - @Override - public void printf(String fmt, Object ... vars) { - if(log.isEnabledFor(level)) { - log.log(level,String.format(fmt,vars)); - } - } + /* (non-Javadoc) + * @see com.att.inno.env.LogTarget#printf(java.lang.String, java.lang.String[]) + */ + @Override + public void printf(String fmt, Object ... vars) { + if (log.isEnabledFor (level)) { + log.log(level,String.format(fmt,vars)); + } + } - public static void setLog4JEnv(String loggerName, BasicEnv env) throws APIException { - env.fatal = new Log4JLogTarget(loggerName,Level.FATAL); - env.error = new Log4JLogTarget(loggerName,Level.ERROR); - env.warn = env.audit = env.init = new Log4JLogTarget(loggerName,Level.WARN); - env.info = new Log4JLogTarget(loggerName,Level.INFO); - env.debug = new Log4JLogTarget(loggerName,Level.DEBUG); - env.trace = new Log4JLogTarget(loggerName,Level.TRACE); - } - + public static void setLog4JEnv(String loggerName, BasicEnv env) throws APIException { + env.fatal = new Log4JLogTarget(loggerName,Level.FATAL); + env.error = new Log4JLogTarget(loggerName,Level.ERROR); + env.warn = env.audit = env.init = new Log4JLogTarget(loggerName,Level.WARN); + env.info = new Log4JLogTarget(loggerName,Level.INFO); + env.debug = new Log4JLogTarget(loggerName,Level.DEBUG); + env.trace = new Log4JLogTarget(loggerName,Level.TRACE); + } + } \ No newline at end of file