KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > util > monolog > wrapper > remote > api > LoggerInfo


1 /**
2  * Copyright (C) 2001-2005 France Telecom R&D
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library 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 GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */

18 package org.objectweb.util.monolog.wrapper.remote.api;
19
20 import org.objectweb.util.monolog.api.BasicLevel;
21 import org.objectweb.util.monolog.api.Handler;
22 import org.objectweb.util.monolog.api.TopicalLogger;
23
24 import java.io.Serializable JavaDoc;
25
26 /**
27  * Defines an holder of information about a logger.
28  *
29  * @author S.Chassande-Barrioz
30  */

31 public class LoggerInfo implements Serializable JavaDoc {
32     
33     /**
34      * contains the topic list of the logger.
35      */

36     public String JavaDoc[] topics;
37     
38     /**
39      * is the int value of the current logger level
40      */

41     public int level;
42     
43     /**
44      * is the name of the current logger level
45      */

46     public String JavaDoc levelName;
47     
48     /**
49      * Is the list of the handler assigned to the logger
50      */

51     public String JavaDoc[] handlerNames;
52     
53     /**
54      * Indicates if the logger inherits handlers from its parent.
55      */

56     public boolean additivity;
57
58     /**
59      * Build a Loggerinfo from a TopicalLogger.
60      * @param l is the TopicalLogger
61      */

62     public LoggerInfo(TopicalLogger l) {
63         topics = l.getTopic();
64         level = l.getCurrentIntLevel();
65         levelName = l.getCurrentLevel().getName();
66         Handler[] hs = l.getHandler();
67         handlerNames = new String JavaDoc[hs.length];
68         for(int i=0; i<hs.length; i++) {
69             handlerNames[i] = hs[i].getName();
70         }
71         additivity = l.getAdditivity();
72     }
73     
74     public boolean isAdditivity() {
75         return additivity;
76     }
77     public void setAdditivity(boolean additivity) {
78         this.additivity = additivity;
79     }
80     public String JavaDoc[] getHandlerNames() {
81         return handlerNames;
82     }
83     public void setHandlerNames(String JavaDoc[] handlerNames) {
84         this.handlerNames = handlerNames;
85     }
86     public int getLevel() {
87         return level;
88     }
89     public void setLevel(int level) {
90         this.level = level;
91     }
92     public String JavaDoc getLevelName() {
93         return levelName;
94     }
95     public void setLevelName(String JavaDoc levelName) {
96         this.levelName = levelName;
97     }
98     public String JavaDoc[] getTopics() {
99         return topics;
100     }
101     public void setTopics(String JavaDoc[] topics) {
102         this.topics = topics;
103     }
104     
105     public String JavaDoc toString() {
106         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
107         sb.append("topic=[");
108         for (int i = 0; i < topics.length; i++) {
109             if (i != 0) {
110                 sb.append(", ");
111             }
112             sb.append(topics[i]);
113         }
114         sb.append("]");
115
116         sb.append(", level=[");
117         sb.append(levelName);
118         sb.append("]");
119
120         if (handlerNames.length > 0) {
121             sb.append(", handler=[");
122             for (int i = 0; i < handlerNames.length; i++) {
123                 if (i != 0) {
124                     sb.append(", ");
125                 }
126                 sb.append(handlerNames[i]);
127             }
128             sb.append("]");
129         }
130         if (!additivity) {
131             sb.append(", no handler inherited");
132         }
133         return sb.toString();
134     }
135 }
136
Popular Tags