View Javadoc
1   package org.newdawn.slick.util;
2   
3   import org.slf4j.Logger;
4   import org.slf4j.LoggerFactory;
5   
6   import javax.annotation.Nonnull;
7   import java.util.Date;
8   
9   /**
10   * The default implementation that just spits the messages out to stdout
11   *
12   * @author kevin, Peter Colapietro
13   *
14   * Updated on 2014-11-10 to use org.slf4j.Logger instead of java.io.PrintStream
15   */
16  public class DefaultLogSystem implements LogSystem {
17      /**
18       * The Logger for dumping the log out on
19       */
20      private static final Logger out = LoggerFactory.getLogger(DefaultLogSystem.class);
21  
22      /**
23       * Log an error
24       *
25       * @param message The message describing the error
26       * @param e       The exception causing the error
27       */
28      public void error(String message, @Nonnull Throwable e) {
29          error(message);
30          error(e);
31      }
32  
33      /**
34       * Log an error
35       *
36       * @param e The exception causing the error
37       */
38      public void error(@Nonnull Throwable e) {
39          out.error(new Date() + " ERROR:" + e.getMessage());
40      }
41  
42      /**
43       * Log an error
44       *
45       * @param message The message describing the error
46       */
47      public void error(String message) {
48          out.error(new Date() + " ERROR:" + message);
49      }
50  
51      /**
52       * Log a warning
53       *
54       * @param message The message describing the warning
55       */
56      public void warn(String message) {
57          out.warn(new Date() + " WARN:" + message);
58      }
59  
60      /**
61       * Log an information message
62       *
63       * @param message The message describing the infomation
64       */
65      public void info(String message) {
66          out.info(new Date() + " INFO:" + message);
67      }
68  
69      /**
70       * Log a debug message
71       *
72       * @param message The message describing the debug
73       */
74      public void debug(String message) {
75          out.debug(new Date() + " DEBUG:" + message);
76      }
77  
78      /**
79       * Log a warning with an exception that caused it
80       *
81       * @param message The message describing the warning
82       * @param e       The cause of the warning
83       */
84      public void warn(String message, Throwable e) {
85          warn(message);
86      }
87  }