RunnableLogger.java

  1. /*
  2.  * GovWay - A customizable API Gateway
  3.  * https://govway.org
  4.  *
  5.  * Copyright (c) 2005-2025 Link.it srl (https://link.it).
  6.  *
  7.  * This program is free software: you can redistribute it and/or modify
  8.  * it under the terms of the GNU General Public License version 3, as published by
  9.  * the Free Software Foundation.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18.  *
  19.  */

  20. package org.openspcoop2.utils.threads;

  21. import org.slf4j.Logger;

  22. /**
  23.  * RunnableLogger
  24.  *  
  25.  * @author Poli Andrea (apoli@link.it)
  26.  * @author $Author$
  27.  * @version $Rev$, $Date$
  28.  */
  29. public class RunnableLogger {

  30.     /** Logger utilizzato per debug. */
  31.     private Logger log = null;
  32.    
  33.     /** Nome */
  34.     private String threadName;
  35.     private String prefix = null;
  36.    
  37.     public RunnableLogger(String threadName, Logger log) {
  38.         this.log = log;
  39.         this.threadName = threadName;
  40.         this.prefix = "["+this.threadName+"] ";
  41.     }
  42.    
  43.     public Logger getLog() {
  44.         return this.log;
  45.     }

  46.     public String getThreadName() {
  47.         return this.threadName;
  48.     }

  49.     public String getPrefix() {
  50.         return this.prefix;
  51.     }
  52.    
  53.    
  54.     public void warn(String message,Throwable t) {
  55.         this.log.warn(this.prefix+message,t);
  56.     }
  57.     public void warn(String message) {
  58.         this.log.warn(this.prefix+message);
  59.     }
  60.    
  61.     public void error(String message,Throwable t) {
  62.         this.log.error(this.prefix+message,t);
  63.     }
  64.     public void error(String message) {
  65.         this.log.error(this.prefix+message);
  66.     }
  67.    
  68.     public void info(String message,Throwable t) {
  69.         this.log.info(this.prefix+message,t);
  70.     }
  71.     public void info(String message) {
  72.         this.log.info(this.prefix+message);
  73.     }
  74.    
  75.     public void debug(String message,Throwable t) {
  76.         this.log.debug(this.prefix+message,t);
  77.     }
  78.     public void debug(String message) {
  79.         this.log.debug(this.prefix+message);
  80.     }
  81.    
  82.     public void trace(String message,Throwable t) {
  83.         this.log.trace(this.prefix+message,t);
  84.     }
  85.     public void trace(String message) {
  86.         this.log.trace(this.prefix+message);
  87.     }
  88. }