Rev 1964 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1964 | Rev 1990 | ||
|---|---|---|---|
| Line 65... | Line 65... | ||
| 65 | } |
65 | } |
| 66 | 66 | ||
| 67 | if (level_string.find("LOG_LEVEL_DEBUG") != std::string::npos) |
67 | if (level_string.find("LOG_LEVEL_DEBUG") != std::string::npos) |
| 68 | { |
68 | { |
| 69 | level_ = (Level)(level_ | LOG_LEVEL_DEBUG); |
69 | level_ = (Level)(level_ | LOG_LEVEL_DEBUG); |
| - | 70 | } |
|
| - | 71 | ||
| - | 72 | if (level_string.find("LOG_LEVEL_EXTREME") != std::string::npos) |
|
| - | 73 | { |
|
| - | 74 | level_ = (Level)(level_ | LOG_LEVEL_EXTREME); |
|
| 70 | } |
75 | } |
| 71 | 76 | ||
| 72 | if (level_string.find("LOG_LEVEL_ALL") != std::string::npos) |
77 | if (level_string.find("LOG_LEVEL_ALL") != std::string::npos) |
| 73 | { |
78 | { |
| 74 | level_ = (Level)(level_ | LOG_LEVEL_ALL); |
79 | level_ = (Level)(level_ | LOG_LEVEL_ALL); |
| Line 83... | Line 88... | ||
| 83 | 88 | ||
| 84 | return file_.is_open(); |
89 | return file_.is_open(); |
| 85 | } |
90 | } |
| 86 | 91 | ||
| 87 | void CloseFile(void) |
92 | void CloseFile(void) |
| 88 | { |
93 | { |
| 89 | if (file_.is_open()) |
94 | if (file_.is_open()) |
| 90 | { |
95 | { |
| 91 | file_.close(); |
96 | file_.close(); |
| 92 | } |
97 | } |
| 93 | } |
98 | } |
| Line 116... | Line 121... | ||
| 116 | level_string = "INFO"; |
121 | level_string = "INFO"; |
| 117 | } |
122 | } |
| 118 | else if (0 != (level & LOG_LEVEL_DEBUG)) |
123 | else if (0 != (level & LOG_LEVEL_DEBUG)) |
| 119 | { |
124 | { |
| 120 | level_string = "DEBUG"; |
125 | level_string = "DEBUG"; |
| 121 | } |
126 | } |
| 122 | else if (0 != (level & LOG_LEVEL_EXCEPTION)) |
127 | else if (0 != (level & LOG_LEVEL_EXCEPTION)) |
| 123 | { |
128 | { |
| 124 | level_string = "EXCEPTION"; |
129 | level_string = "EXCEPTION"; |
| 125 | } |
130 | } |
| 126 | else if (0 != (level & LOG_LEVEL_WARNING)) |
131 | else if (0 != (level & LOG_LEVEL_WARNING)) |
| 127 | { |
132 | { |
| 128 | level_string = "WARNING"; |
133 | level_string = "WARNING"; |
| - | 134 | } |
|
| - | 135 | else if (0 != (level & LOG_LEVEL_EXTREME)) |
|
| - | 136 | { |
|
| - | 137 | level_string = "EXTREME"; |
|
| 129 | } |
138 | } |
| 130 | else |
139 | else |
| 131 | { |
140 | { |
| 132 | level_string = "UNKNOWN"; |
141 | level_string = "UNKNOWN"; |
| 133 | } |
142 | } |
| Line 149... | Line 158... | ||
| 149 | 158 | ||
| 150 | 159 | ||
| 151 | if (file_.is_open()) |
160 | if (file_.is_open()) |
| 152 | { |
161 | { |
| 153 | file_ << log_string << std::endl; |
162 | file_ << log_string << std::endl; |
| 154 | } |
163 | } |
| 155 | 164 | ||
| 156 | std::cout.imbue(std::locale::classic()); |
165 | std::cout.imbue(std::locale::classic()); |
| 157 | 166 | ||
| 158 | mutex_.unlock(); |
167 | mutex_.unlock(); |
| 159 | } |
168 | } |
| 160 | 169 | ||
| 161 | void Info(std::string module, char* format, ...) |
170 | void Info(std::string module, char* format, ...) |
| 162 | { |
171 | { |
| - | 172 | char buffer[kMaxBufferSize]; |
|
| - | 173 | va_list parameters; |
|
| - | 174 | ||
| - | 175 | ||
| - | 176 | /* Initialize variables */ |
|
| - | 177 | memset(&buffer[0], 0, sizeof(buffer)); |
|
| - | 178 | ||
| - | 179 | ||
| - | 180 | /* Construct message */ |
|
| - | 181 | va_start(parameters, format); |
|
| - | 182 | vsnprintf(&buffer[0], sizeof(buffer), format, parameters); |
|
| - | 183 | va_end(parameters); |
|
| - | 184 | ||
| - | 185 | Print(LOG_LEVEL_INFO, module, &buffer[0]); |
|
| - | 186 | } |
|
| - | 187 | ||
| - | 188 | void Info(std::string module, std::string message) |
|
| - | 189 | { |
|
| - | 190 | Print(LOG_LEVEL_INFO, module, message); |
|
| - | 191 | } |
|
| - | 192 | ||
| - | 193 | void Debug(std::string module, char* format, ...) |
|
| - | 194 | { |
|
| 163 | char buffer[kMaxBufferSize]; |
195 | char buffer[kMaxBufferSize]; |
| 164 | va_list parameters; |
196 | va_list parameters; |
| 165 | 197 | ||
| 166 | 198 | ||
| 167 | /* Initialize variables */ |
199 | /* Initialize variables */ |
| 168 | memset(&buffer[0], 0, sizeof(buffer)); |
200 | memset(&buffer[0], 0, sizeof(buffer)); |
| 169 | 201 | ||
| 170 | 202 | ||
| 171 | /* Construct message */ |
203 | /* Construct message */ |
| 172 | va_start(parameters, format); |
204 | va_start(parameters, format); |
| 173 | vsnprintf(&buffer[0], sizeof(buffer), format, parameters); |
205 | vsnprintf(&buffer[0], sizeof(buffer), format, parameters); |
| 174 | va_end(parameters); |
206 | va_end(parameters); |
| 175 | 207 | ||
| 176 | Print( |
208 | Print(LOG_LEVEL_DEBUG, module, &buffer[0]); |
| - | 209 | } |
|
| - | 210 | ||
| - | 211 | void Debug(std::string module, std::string message) |
|
| - | 212 | { |
|
| - | 213 | Print(LOG_LEVEL_DEBUG, module, message); |
|
| 177 | } |
214 | } |
| 178 | 215 | ||
| 179 | void Info(std::string module, std::string message) |
- | |
| 180 | { |
- | |
| 181 | Print(LOG_LEVEL_INFO, module, message); |
- | |
| 182 | } |
- | |
| 183 | - | ||
| 184 | void |
216 | void Extreme(std::string module, char* format, ...) |
| 185 | { |
217 | { |
| 186 | char buffer[kMaxBufferSize]; |
218 | char buffer[kMaxBufferSize]; |
| 187 | va_list parameters; |
219 | va_list parameters; |
| 188 | 220 | ||
| 189 | 221 | ||
| 190 | /* Initialize variables */ |
222 | /* Initialize variables */ |
| 191 | memset(&buffer[0], 0, sizeof(buffer)); |
223 | memset(&buffer[0], 0, sizeof(buffer)); |
| 192 | 224 | ||
| 193 | 225 | ||
| 194 | /* Construct message */ |
226 | /* Construct message */ |
| 195 | va_start(parameters, format); |
227 | va_start(parameters, format); |
| 196 | vsnprintf(&buffer[0], sizeof(buffer), format, parameters); |
228 | vsnprintf(&buffer[0], sizeof(buffer), format, parameters); |
| 197 | va_end(parameters); |
229 | va_end(parameters); |
| 198 | 230 | ||
| 199 | Print( |
231 | Print(LOG_LEVEL_EXTREME, module, &buffer[0]); |
| 200 | } |
232 | } |
| 201 | 233 | ||
| 202 | void |
234 | void Extreme(std::string module, std::string message) |
| 203 | { |
235 | { |
| 204 | Print( |
236 | Print(LOG_LEVEL_EXTREME, module, message); |
| 205 | } |
237 | } |
| 206 | 238 | ||
| 207 | void Error(std::string module, char* format, ...) |
239 | void Error(std::string module, char* format, ...) |
| 208 | { |
240 | { |
| 209 | char buffer[kMaxBufferSize]; |
241 | char buffer[kMaxBufferSize]; |