annotate src/goodjava/logger/GoodLoggerFactory.java @ 1448:6fc083e1d08c

start logger
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 23 Feb 2020 18:14:32 -0700
parents
children 28b1ddacfad3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1448
6fc083e1d08c start logger
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1 package goodjava.logger;
6fc083e1d08c start logger
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
2
6fc083e1d08c start logger
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
3 import java.util.Map;
6fc083e1d08c start logger
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
4 import java.util.HashMap;
6fc083e1d08c start logger
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
5 import goodjava.logging.ILoggerFactory;
6fc083e1d08c start logger
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
6 import goodjava.logging.Logger;
6fc083e1d08c start logger
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
7
6fc083e1d08c start logger
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
8
6fc083e1d08c start logger
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
9 public class GoodLoggerFactory implements ILoggerFactory {
6fc083e1d08c start logger
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
10 private final Map<String,GoodLogger> map = new HashMap<String,GoodLogger>();
6fc083e1d08c start logger
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
11
6fc083e1d08c start logger
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
12 @Override public synchronized Logger getLogger(String name) {
6fc083e1d08c start logger
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
13 GoodLogger logger = map.get(name);
6fc083e1d08c start logger
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
14 if( logger == null ) {
6fc083e1d08c start logger
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
15 logger = new GoodLogger(name);
6fc083e1d08c start logger
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
16 map.put(name,logger);
6fc083e1d08c start logger
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
17 }
6fc083e1d08c start logger
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
18 return logger;
6fc083e1d08c start logger
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
19 }
6fc083e1d08c start logger
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
20 }