]> git.mxchange.org Git - jcore-logger-ejb.git/blob - src/java/org/mxchange/jcoreeelogger/beans/local/logger/LoggerBean.java
Changed copyright notice to the FSF, so after my death they will continue my
[jcore-logger-ejb.git] / src / java / org / mxchange / jcoreeelogger / beans / local / logger / LoggerBean.java
1 /*
2  * Copyright (C) 2016, 2017 Free Software Foundation
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Affero General Public License as
6  * published by the Free Software Foundation, either version 3 of the
7  * License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU Affero General Public License for more details.
13  *
14  * You should have received a copy of the GNU Affero General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17 package org.mxchange.jcoreeelogger.beans.local.logger;
18
19 import javax.ejb.Singleton;
20 import javax.ejb.Startup;
21 import javax.inject.Inject;
22 import org.apache.logging.log4j.Logger;
23
24 /**
25  * A "centralized" logger bean
26  * <p>
27  * @author Roland Häder<roland@mxchange.org>
28  */
29 @Startup
30 @Singleton (name = "logger", description = "A centralized logger bean")
31 public class LoggerBean implements LoggerBeanLocal {
32
33         /**
34          * Serial number
35          */
36         private static final long serialVersionUID = 186_978_639_741_260L;
37
38         /**
39          * Logger instance
40          */
41         @Inject
42         @Log
43         private Logger logger;
44
45         /**
46          * Default constructor
47          */
48         public LoggerBean () {
49         }
50
51         @Override
52         public void logDebug (final String message) {
53                 // Deligate to logger
54                 this.getLogger().debug(message);
55         }
56
57         @Override
58         public void logDebug (final String message, final Throwable cause) {
59                 // Deligate to logger
60                 this.getLogger().debug(message, cause);
61         }
62
63         @Override
64         public void logError (final String message) {
65                 // Deligate to logger
66                 this.getLogger().error(message);
67         }
68
69         @Override
70         public void logError (final String message, final Throwable cause) {
71                 // Deligate to logger
72                 this.getLogger().error(message, cause);
73         }
74
75         @Override
76         public void logException (final Throwable throwable) {
77                 // Deligate to logger
78                 this.getLogger().catching(throwable);
79         }
80
81         @Override
82         public void logFatal (final String message, final Throwable cause) {
83                 // Deligate to logger
84                 this.getLogger().fatal(message, cause);
85         }
86
87         @Override
88         public void logFatal (final String message) {
89                 // Deligate to logger
90                 this.getLogger().fatal(message);
91         }
92
93         @Override
94         public void logInfo (final String message) {
95                 // Deligate to logger
96                 this.getLogger().info(message);
97         }
98
99         @Override
100         public void logInfo (final String message, final Throwable cause) {
101                 // Deligate to logger
102                 this.getLogger().info(message, cause);
103         }
104
105         @Override
106         public void logTrace (final String message) {
107                 // Deligate to logger
108                 this.getLogger().trace(message);
109         }
110
111         @Override
112         public void logTrace (final String message, final Throwable cause) {
113                 // Deligate to logger
114                 this.getLogger().trace(message, cause);
115         }
116
117         @Override
118         public void logWarning (final String message) {
119                 // Deligate to logger
120                 this.getLogger().warn(message);
121         }
122
123         @Override
124         public void logWarning (final String message, final Throwable cause) {
125                 // Deligate to logger
126                 this.getLogger().warn(message, cause);
127         }
128
129         /**
130          * Getter for logger
131          * <p>
132          * @return Logger
133          */
134         private Logger getLogger () {
135                 return this.logger;
136         }
137
138 }