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.FATAL_INT:
94 case Priority.ERROR_INT:
95 case Priority.WARN_INT:
96 case Priority.INFO_INT:
97 case Priority.DEBUG_INT:
103 public void info(Object o)
108 public void info(Object o, Throwable e)
112 case Priority.FATAL_INT:
113 case Priority.ERROR_INT:
114 case Priority.WARN_INT:
115 case Priority.INFO_INT:
122 public void warn(Object o)
127 public void warn(Object o, Throwable e)
131 case Priority.FATAL_INT:
132 case Priority.ERROR_INT:
133 case Priority.WARN_INT:
140 public void error(Object o)
145 public void error(Object o, Throwable e)
149 case Priority.FATAL_INT:
150 case Priority.ERROR_INT:
157 private void log(Object s, Throwable e)
161 case Priority.ERROR_INT:
162 if (appender == null)
164 System.err.println(s);
168 case Priority.WARN_INT:
169 if (appender == null)
171 System.err.println(s);
175 case Priority.INFO_INT:
176 if (appender == null)
178 System.out.println(s);
182 case Priority.DEBUG_INT:
183 if (appender == null)
185 System.out.println(s);
191 appender.append(new LoggingEvent(this, s.toString(), level));