X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=misc%2Fenv%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faaf%2Fmisc%2Fenv%2Fimpl%2FJavaUtilLogTarget.java;h=ac3e8b45da14c57bb29423a7069fcb64c97b23b8;hb=f51ee23763fd379388753dae419c2e7358fce8cd;hp=84a78bfdb671071d2548161667cf1dbc08f0fcfe;hpb=4ae2b76732fc04aaab62b8449a003d470e6c99ba;p=aaf%2Fauthz.git diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/impl/JavaUtilLogTarget.java b/misc/env/src/main/java/org/onap/aaf/misc/env/impl/JavaUtilLogTarget.java index 84a78bfd..ac3e8b45 100644 --- a/misc/env/src/main/java/org/onap/aaf/misc/env/impl/JavaUtilLogTarget.java +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/impl/JavaUtilLogTarget.java @@ -1,90 +1,90 @@ -/** - * ============LICENSE_START==================================================== - * org.onap.aaf - * =========================================================================== - * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. - * =========================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END==================================================== - * - */ - -package org.onap.aaf.misc.env.impl; - -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.onap.aaf.misc.env.LogTarget; - -/** - * This LogTarget Implementation is included mostly because the JavaUtil based logging is included in the - * JDK. This makes the default implementation independent of any external Jars. - * - * Log4j is often considered more Enterprise capable. See Log4JLogTarget for that implementation - * - * @author Jonathan - * - */ -public class JavaUtilLogTarget implements LogTarget { - private Level level; - private Logger log; - - public JavaUtilLogTarget(Logger logger, Level theLevel) { - log = logger; - level = theLevel; - } - - public boolean isLoggable() { - return log.isLoggable(level); - } - - public void log(Object ... msgs) { - if(log.isLoggable(level)) { - StringBuilder sb = new StringBuilder(); - String msg; - for(int i=0;i0) { - 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()); - } - } - - public void log(Throwable e, Object ... msgs) { - String str = e.getLocalizedMessage(); - if(str==null) { - str = e.getMessage(); - } - if(str==null) { - str = e.getClass().getName(); - } - log.log(level,str,msgs); - } - - /* (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.isLoggable(level)) { - log.log(level,String.format(fmt,vars)); - } - } -} +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END==================================================== + * + */ + +package org.onap.aaf.misc.env.impl; + +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.onap.aaf.misc.env.LogTarget; + +/** + * This LogTarget Implementation is included mostly because the JavaUtil based logging is included in the + * JDK. This makes the default implementation independent of any external Jars. + * + * Log4j is often considered more Enterprise capable. See Log4JLogTarget for that implementation + * + * @author Jonathan + * + */ +public class JavaUtilLogTarget implements LogTarget { + private Level level; + private Logger log; + + public JavaUtilLogTarget(Logger logger, Level theLevel) { + log = logger; + level = theLevel; + } + + public boolean isLoggable() { + return log.isLoggable(level); + } + + public void log(Object ... msgs) { + if(log.isLoggable(level)) { + StringBuilder sb = new StringBuilder(); + String msg; + for(int i=0;i0) { + 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()); + } + } + + public void log(Throwable e, Object ... msgs) { + String str = e.getLocalizedMessage(); + if(str==null) { + str = e.getMessage(); + } + if(str==null) { + str = e.getClass().getName(); + } + log.log(level,str,msgs); + } + + /* (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.isLoggable(level)) { + log.log(level,String.format(fmt,vars)); + } + } +}