Source Code Cross Referenced for MonologLogChannel.java in  » J2EE » Enhydra-Application-Framework » com » lutris » logging » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » Enhydra Application Framework » com.lutris.logging 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Enhydra Java Application Server Project
003:         * 
004:         * The contents of this file are subject to the Enhydra Public License
005:         * Version 1.1 (the "License"); you may not use this file except in
006:         * compliance with the License. You may obtain a copy of the License on
007:         * the Enhydra web site ( http://www.enhydra.org/ ).
008:         * 
009:         * Software distributed under the License is distributed on an "AS IS"
010:         * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 
011:         * the License for the specific terms governing rights and limitations
012:         * under the License.
013:         * 
014:         * The Initial Developer of the Enhydra Application Server is Lutris
015:         * Technologies, Inc. The Enhydra Application Server and portions created
016:         * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
017:         * All Rights Reserved.
018:         * 
019:         * Contributor(s):
020:         * 
021:         * $Id: MonologLogChannel.java,v 1.3 2007-10-19 10:05:39 sinisa Exp $
022:         */
023:        package com.lutris.logging;
024:
025:        import java.text.SimpleDateFormat;
026:
027:        import org.objectweb.util.monolog.api.BasicLevel;
028:        import org.objectweb.util.monolog.api.Level;
029:
030:        //import org.objectweb.util.monolog.file.monolog.PropertiesConfAccess;
031:
032:        /**
033:         * Monolog implementation of a channel associated with a logging
034:         * facility.  All messages for the facility are written using a channel.
035:         * Care is take to avoid synchronization when possible for performance
036:         * reasons.
037:         *
038:         * @author Sinisa Milosevic
039:         * @see com.lutris.logging.LogChannel
040:         * @see com.lutris.logging.Log4jLogger
041:         */
042:        public class MonologLogChannel implements  LogChannel {
043:
044:            /**
045:             * Our symbolic name.
046:             */
047:            String separatorLine = "";
048:            //    private String facility;
049:
050:            private static final int INT_ERROR = -1;
051:
052:            /**
053:             * Format for the date.
054:             */
055:            private static final SimpleDateFormat dateFormatter = new SimpleDateFormat(
056:                    "yyyy.MM.dd HH:mm:ss");
057:
058:            /**
059:             * Logger object with which we are associated.
060:             */
061:            private org.objectweb.util.monolog.api.Logger logger;
062:
063:            /**
064:             * Construct a new log channel.
065:             *
066:             * @param chanFacility The facility that the channel is associate with.
067:             * @param loggerObj The logging object that this channel will be associated
068:             *  with.
069:             */
070:            protected MonologLogChannel(String chanFacility,
071:                    org.objectweb.util.monolog.api.Logger loggerObj,
072:                    String separator) {
073:                //        facility = chanFacility;
074:                logger = loggerObj;
075:                separatorLine = separator;
076:            }
077:
078:            public int getLevel(String level) {
079:                if (logger != null) {
080:                    return logger.getCurrentIntLevel();
081:                }
082:                return INT_ERROR;
083:            }
084:
085:            /**
086:             * Determine if logging is enabled for the specified level.
087:             */
088:            public boolean isEnabled(int level) {
089:                return true;
090:                // return logger.isEnabledFor(intToLevel(level));
091:            }
092:
093:            /**
094:             * Determine if logging is enabled for the specified level.
095:             */
096:            public boolean isEnabled(String level) {
097:                return true;
098:            }
099:
100:            /**
101:             * Write a string to the log file.
102:             */
103:            public void write(int level, String msg) {
104:                Level lev;
105:
106:                lev = intToLevel(level);
107:                if (lev == null) {
108:                    lev = BasicLevel.LEVEL_INFO;
109:                }
110:                logger.log(lev, msg + separatorLine);
111:            }
112:
113:            /**
114:             * Write a string and exception to the log file.
115:             */
116:            public void write(int level, String msg, Throwable throwable) {
117:                Level lev;
118:
119:                lev = intToLevel(level);
120:                if (lev == null) {
121:                    lev = BasicLevel.LEVEL_INFO;
122:                }
123:                logger.log(lev, msg + separatorLine, throwable);
124:            }
125:
126:            /**
127:             * Write a string to the log file.
128:             */
129:            public void write(String level, String msg) {
130:                Level lev;
131:
132:                lev = stringToLevel(level);
133:                if (lev == null) {
134:                    lev = BasicLevel.LEVEL_INFO;
135:                }
136:                logger.log(lev, msg + separatorLine);
137:            }
138:
139:            /**
140:             * Write a string and exception to the log file.
141:             */
142:            public void write(String level, String msg, Throwable throwable) {
143:                Level lev;
144:                lev = stringToLevel(level);
145:                if (lev == null) {
146:                    lev = BasicLevel.LEVEL_INFO;
147:                }
148:                logger.log(lev, msg + separatorLine, throwable);
149:            }
150:
151:            private Level intToLevel(int level) {
152:                Level lev;
153:
154:                switch (level) {
155:                case com.lutris.logging.Logger.EMERGENCY:
156:                case com.lutris.logging.Logger.ALERT:
157:                    lev = BasicLevel.LEVEL_FATAL;
158:                    break;
159:
160:                case com.lutris.logging.Logger.CRITICAL:
161:                case com.lutris.logging.Logger.ERROR:
162:                    lev = BasicLevel.LEVEL_ERROR;
163:                    break;
164:
165:                case com.lutris.logging.Logger.WARNING:
166:                    lev = BasicLevel.LEVEL_WARN;
167:                    break;
168:
169:                case com.lutris.logging.Logger.NOTICE:
170:                case com.lutris.logging.Logger.INFO:
171:                    lev = BasicLevel.LEVEL_INFO;
172:                    break;
173:
174:                case com.lutris.logging.Logger.DEBUG:
175:                case com.lutris.logging.Logger.DEBUG1:
176:                case com.lutris.logging.Logger.DEBUG2:
177:                case com.lutris.logging.Logger.DEBUG3:
178:                case com.lutris.logging.Logger.DEBUG4:
179:                case com.lutris.logging.Logger.DEBUG5:
180:                case com.lutris.logging.Logger.DEBUG6:
181:                case com.lutris.logging.Logger.DEBUG7:
182:                case com.lutris.logging.Logger.DEBUG8:
183:                case com.lutris.logging.Logger.DEBUG9:
184:                case com.lutris.logging.Logger.DEBUGTMP:
185:                    lev = BasicLevel.LEVEL_DEBUG;
186:                    break;
187:
188:                default:
189:                    lev = BasicLevel.LEVEL_DEBUG;
190:                } // end switch (level)
191:                return lev;
192:            }
193:
194:            private Level stringToLevel(String level) {
195:                Level lev;
196:
197:                if (level.equalsIgnoreCase("EMERGENCY")
198:                        || level.equalsIgnoreCase("ALERT")) {
199:                    lev = BasicLevel.LEVEL_FATAL;
200:                } else if (level.equalsIgnoreCase("CRITICAL")
201:                        || level.equalsIgnoreCase("ERROR")) {
202:                    lev = BasicLevel.LEVEL_ERROR;
203:                } else if (level.equalsIgnoreCase("WARNING")) {
204:                    lev = BasicLevel.LEVEL_WARN;
205:                } else if (level.equalsIgnoreCase("NOTICE")
206:                        || level.equalsIgnoreCase("INFO")) {
207:                    lev = BasicLevel.LEVEL_INFO;
208:                } else if (level.equalsIgnoreCase("DEBUG")
209:                        || level.equalsIgnoreCase("DEBUG1")
210:                        || level.equalsIgnoreCase("DEBUG2")
211:                        || level.equalsIgnoreCase("DEBUG3")
212:                        || level.equalsIgnoreCase("DEBUG4")
213:                        || level.equalsIgnoreCase("DEBUG5")
214:                        || level.equalsIgnoreCase("DEBUG6")
215:                        || level.equalsIgnoreCase("DEBUG7")
216:                        || level.equalsIgnoreCase("DEBUG8")
217:                        || level.equalsIgnoreCase("DEBUG9")
218:                        || level.equalsIgnoreCase("DEBUGTMP")) {
219:                    lev = BasicLevel.LEVEL_DEBUG;
220:                } else {// default
221:                    lev = BasicLevel.LEVEL_DEBUG;
222:                }
223:                return lev;
224:            }
225:
226:            /**
227:             * <b>NOT SUPPORTED</b>
228:             *
229:             * @param level Symbolic level that is to be checked.
230:             * @return A log writer object.
231:             */
232:            public LogWriter getLogWriter(String level) {
233:                return new MonologWriter(this , level);
234:
235:            }
236:
237:            /**
238:             * <b>NOT SUPPORTED</b>
239:             *
240:             * @param level Numeric level that is to be checked.
241:             * @return A log writer object.
242:             */
243:            public LogWriter getLogWriter(int level) {
244:                return new MonologWriter(this, level);
245:            }
246:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.