1 package cz.cuni.amis.pogamut.base.communication.parser.impl.yylex;
2
3 import com.google.inject.Inject;
4
5 import cz.cuni.amis.pogamut.base.utils.guice.AgentScoped;
6 import cz.cuni.amis.pogamut.base.utils.logging.IAgentLogger;
7 import cz.cuni.amis.pogamut.base.utils.logging.LogCategory;
8 import cz.cuni.amis.utils.ExceptionToString;
9 import java.util.logging.Level;
10
11
12
13
14
15 public interface IYylexObserver {
16
17
18
19
20
21
22
23
24
25
26 public void exception(Exception e, String info);
27
28
29
30
31
32
33 public void warning(String info);
34
35
36
37
38
39
40
41 @AgentScoped
42 public static class LogObserver implements IYylexObserver {
43
44 private LogCategory log;
45
46 @Inject
47 public LogObserver(IAgentLogger agentLogger) {
48 log = agentLogger.getCategory("Yylex");
49 }
50
51 @Override
52 public void exception(Exception e, String info) {
53 if (log.isLoggable(Level.SEVERE)) log.severe(ExceptionToString.process(info, e));
54 }
55
56 @Override
57 public void warning(String info) {
58 if (log.isLoggable(Level.WARNING)) log.warning(info);
59 }
60
61 }
62
63 }