Changeset 2081
- Timestamp:
- 31/01/2008 23:44:54 (4 years ago)
- Location:
- box/trunk/lib
- Files:
-
- 3 edited
-
common/Logging.cpp (modified) (6 diffs)
-
common/Logging.h (modified) (2 diffs)
-
server/Daemon.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
box/trunk/lib/common/Logging.cpp
r2001 r2081 183 183 bool Console::sShowTimeMicros = false; 184 184 bool Console::sShowTag = false; 185 bool Console::sShowPID = false; 185 186 std::string Console::sTag; 186 187 … … 201 202 } 202 203 204 void Console::SetShowPID(bool enabled) 205 { 206 sShowPID = enabled; 207 } 208 203 209 bool Console::Log(Log::Level level, const std::string& rFile, 204 210 int line, std::string& rMessage) … … 216 222 } 217 223 218 std:: string msg;224 std::ostringstream buf; 219 225 220 226 if (sShowTime) … … 232 238 #endif 233 239 { 234 std::ostringstream buf;235 236 240 buf << std::setfill('0') << 237 241 std::setw(2) << tm_ptr->tm_hour << ":" << … … 245 249 246 250 buf << " "; 247 msg += buf.str();248 251 } 249 252 else 250 253 { 251 msg +=strerror(errno);252 msg +=" ";254 buf << strerror(errno); 255 buf << " "; 253 256 } 254 257 } … … 256 259 if (sShowTag) 257 260 { 258 msg += "[" + sTag + "] "; 261 if (sShowPID) 262 { 263 buf << "[" << sTag << " " << getpid() << "] "; 264 } 265 else 266 { 267 buf << "[" << sTag << "] "; 268 } 269 } 270 else if (sShowPID) 271 { 272 buf << "[" << getpid() << "] "; 259 273 } 260 274 261 275 if (level <= Log::FATAL) 262 276 { 263 msg += "FATAL:";277 buf << "FATAL: "; 264 278 } 265 279 else if (level <= Log::ERROR) 266 280 { 267 msg += "ERROR:";281 buf << "ERROR: "; 268 282 } 269 283 else if (level <= Log::WARNING) 270 284 { 271 msg +="WARNING: ";285 buf << "WARNING: "; 272 286 } 273 287 else if (level <= Log::NOTICE) 274 288 { 275 msg += "NOTICE: "; 276 } 277 278 msg += rMessage; 279 280 fprintf(target, "%s\n", msg.c_str()); 289 buf << "NOTICE: "; 290 } 291 else if (level <= Log::INFO) 292 { 293 buf << "INFO: "; 294 } 295 else if (level <= Log::TRACE) 296 { 297 buf << "TRACE: "; 298 } 299 300 buf << rMessage; 301 302 fprintf(target, "%s\n", buf.str().c_str()); 281 303 282 304 return true; -
box/trunk/lib/common/Logging.h
r2001 r2081 122 122 static bool sShowTag; 123 123 static std::string sTag; 124 static bool sShowPID; 124 125 125 126 public: … … 132 133 static void SetShowTime(bool enabled); 133 134 static void SetShowTimeMicros(bool enabled); 135 static void SetShowPID(bool enabled); 134 136 }; 135 137 -
box/trunk/lib/server/Daemon.cpp
r2021 r2081 107 107 "DFk" 108 108 #endif 109 "h qvVt:T";109 "hPqvVt:TU"; 110 110 } 111 111 … … 126 126 " -k Keep console open after fork, keep writing log messages to it\n" 127 127 #endif 128 " -P Show process ID (PID) in console output\n" 128 129 " -q Run more quietly, reduce verbosity level by one, can repeat\n" 129 130 " -v Run more verbosely, increase verbosity level by one, can repeat\n" 130 131 " -V Run at maximum verbosity\n" 131 132 " -t <tag> Tag console output with specified marker\n" 132 " -T Timestamp console output\n"; 133 " -T Timestamp console output\n" 134 " -U Timestamp console output with microseconds\n"; 133 135 } 134 136 … … 182 184 break; 183 185 186 case 'P': 187 { 188 Console::SetShowPID(true); 189 } 190 break; 191 184 192 case 'q': 185 193 { … … 223 231 { 224 232 Console::SetShowTime(true); 233 } 234 break; 235 236 case 'U': 237 { 238 Console::SetShowTime(true); 239 Console::SetShowTimeMicros(true); 225 240 } 226 241 break;
Note: See TracChangeset
for help on using the changeset viewer.
