Clover.NET coverage report - Coverage for s2container.net

Coverage timestamp: 2006年5月30日 11:21:29

File Stats: LOC: 192   Methods: 18
NCLOC: 138 Classes: 1
 
Source File Conditionals Statements Methods TOTAL
Seasar.Framework.Log\Logger.cs 50.0% 66.0% 66.7% 63.6%
coverage coverage
1   #region Copyright
2   /*
3   * Copyright 2005 the Seasar Foundation and the Others.
4   *
5   * Licensed under the Apache License, Version 2.0 (the "License");
6   * you may not use this file except in compliance with the License.
7   * You may obtain a copy of the License at
8   *
9   * http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
14   * either express or implied. See the License for the specific language
15   * governing permissions and limitations under the License.
16   */
17   #endregion
18  
19   using System;
20   using System.Collections;
21   using log4net;
22   using Seasar.Framework.Message;
23  
24   namespace Seasar.Framework.Log
25   {
26   /// <summary>
27   /// Logger の概要の説明です。
28   /// </summary>
29   public sealed class Logger
30   {
31   private static Hashtable loggerTable_ = Hashtable.Synchronized(new Hashtable());
32   private ILog log_;
33   private Type type_;
34  
35 19 private Logger(Type type)
36   {
37 19 log_ = LogManager.GetLogger(type);
38 19 type_ = type;
39   }
40  
41 20 public static Logger GetLogger(Type type)
42   {
43 20 Logger logger = (Logger) loggerTable_[type];
44 20 if(logger == null)
45   {
46 19 logger = new Logger(type);
47 19 loggerTable_.Add(type,logger);
48   }
49 20 return logger;
50   }
51  
52  
53   public bool IsDebugEnabled
54   {
55 100 get { return log_.IsDebugEnabled; }
56   }
57  
58  
59 0 public void Debug(object message,Exception exception)
60   {
61   if(this.IsDebugEnabled)
62   {
63   log_.Debug(message,exception);
64   }
65   }
66  
67  
68 74 public void Debug(object message)
69   {
70 74 if(this.IsDebugEnabled)
71   {
72 74 log_.Debug(message);
73   }
74   }
75  
76   public bool IsInfoEnabled
77   {
78 1 get { return log_.IsInfoEnabled; }
79   }
80  
81  
82 0 public void Info(object message,Exception exception)
83   {
84   if(this.IsInfoEnabled)
85   {
86   log_.Info(message,exception);
87   }
88   }
89  
90  
91 1 public void Info(object message)
92   {
93 1 if(this.IsInfoEnabled)
94   {
95 1 log_.Info(message);
96   }
97   }
98  
99  
100 0 public void Warn(object message,Exception exception)
101   {
102   log_.Warn(message,exception);
103   }
104  
105  
106 1 public void Warn(object message)
107   {
108 1 log_.Warn(message);
109   }
110  
111  
112 0 public void Error(object message,Exception exception)
113   {
114   log_.Error(message,exception);
115   }
116  
117  
118 1 public void Error(object message)
119   {
120 1 log_.Error(message);
121   }
122  
123  
124 0 public void Fatal(object message,Exception exception)
125   {
126   log_.Fatal(message,exception);
127   }
128  
129  
130 101 public void Fatal(object message)
131   {
132 101 log_.Fatal(message);
133   }
134  
135  
136 0 public void Log(Exception exception)
137   {
138   this.Error(exception.Message,exception);
139   }
140  
141  
142 166 public void Log(string messageCode,object[] args)
143   {
144 166 this.Log(messageCode,args,null);
145   }
146  
147 167 public void Log(string messageCode,object[] args,Exception exception)
148   {
149 167 char messageType = messageCode.ToCharArray()[0];
150 167 if(this.IsEnabledFor(messageType))
151   {
152  
153 164 string message = MessageFormatter.GetSimpleMessage(messageCode,args, type_.Assembly);
154 164 switch(messageType)
155   {
156   case 'D':
157 161 log_.Debug(message,exception);
158 161 break;
159   case 'I':
160 0 log_.Info(message,exception);
161 0 break;
162   case 'W':
163 2 log_.Warn(message,exception);
164 2 break;
165   case 'E':
166 1 log_.Error(message,exception);
167 1 break;
168   case 'F':
169 0 log_.Fatal(message,exception);
170 0 break;
171   default:
172 0 throw new ArgumentException(messageType.ToString());
173   }
174   }
175   }
176  
177  
178 167 private bool IsEnabledFor(char messageType)
179   {
180 167 switch(messageType)
181   {
182 164 case 'D': return log_.IsDebugEnabled;
183 0 case 'I': return log_.IsInfoEnabled;
184 2 case 'W': return log_.IsWarnEnabled;
185 1 case 'E': return log_.IsErrorEnabled;
186 0 case 'F': return log_.IsFatalEnabled;
187 0 default: throw new ArgumentException(new String(messageType,1));
188   }
189   }
190   }
191   }
192