2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.javascript.log4j;
23 import jalview.javascript.log4j.spi.LoggingEvent;
25 import java.util.Hashtable;
31 private static Map<String, Logger> registry;
37 private boolean enabled = true;
39 private boolean isEnabled;
41 private Appender appender;
43 private Logger(String name)
48 public static Logger getLogger(String name)
52 registry = new Hashtable<>();
55 Logger logger = registry.get(name);
58 registry.put(name, logger = new Logger(name));
59 logger.setLevel(Level.INFO);
64 public static Logger getRootLogger()
66 return getLogger("root");
69 public void setLevel(Level l)
74 public void addAppender(Appender appender)
76 this.appender = appender;
79 public boolean isDebugEnabled()
84 public void debug(Object o)
89 public void debug(Object o, Throwable e)
93 case Priority.DEBUG_INT:
99 public void info(Object o)
104 public void info(Object o, Throwable e)
108 case Priority.INFO_INT:
109 case Priority.DEBUG_INT:
116 public void warn(Object o)
121 public void warn(Object o, Throwable e)
125 case Priority.WARN_INT:
126 case Priority.INFO_INT:
127 case Priority.DEBUG_INT:
134 public void error(Object o)
139 public void error(Object o, Throwable e)
143 case Priority.ERROR_INT:
144 case Priority.WARN_INT:
145 case Priority.INFO_INT:
146 case Priority.DEBUG_INT:
153 private void log(Object s, Throwable e)
157 case Priority.ERROR_INT:
158 if (appender == null)
160 System.err.println(s);
164 case Priority.WARN_INT:
165 if (appender == null)
167 System.err.println(s);
171 case Priority.INFO_INT:
172 if (appender == null)
174 System.out.println(s);
178 case Priority.DEBUG_INT:
179 if (appender == null)
181 System.out.println(s);
187 appender.append(new LoggingEvent(this, s.toString(), level));