Changeset 3074
- Timestamp:
- 23/01/2012 01:32:08 (4 months ago)
- Location:
- box/trunk/lib/common
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
box/trunk/lib/common/Box.h
r3073 r3074 17 17 18 18 #include "BoxPlatform.h" 19 20 #include <memory> 19 21 20 22 // uncomment this line to enable full memory leak finding on all … … 105 107 { \ 106 108 if(!HideExceptionMessageGuard::ExceptionsHidden() \ 107 || Logging:: IsEnabled(Log::EVERYTHING)) \109 || Logging::Guard::IsGuardingFrom(Log::EVERYTHING)) \ 108 110 { \ 111 std::auto_ptr<Logging::Guard> guard; \ 112 \ 113 if(Logging::Guard::IsGuardingFrom(Log::EVERYTHING)) \ 114 { \ 115 guard.reset(new Logging::Guard(Log::EVERYTHING)); \ 116 } \ 117 \ 109 118 OPTIONAL_DO_BACKTRACE \ 110 119 BOX_WARNING("Exception thrown: " \ … … 120 129 _box_throw_line << message; \ 121 130 if(!HideExceptionMessageGuard::ExceptionsHidden() \ 122 || Logging:: IsEnabled(Log::EVERYTHING)) \131 || Logging::Guard::IsGuardingFrom(Log::EVERYTHING)) \ 123 132 { \ 133 std::auto_ptr<Logging::Guard> guard; \ 134 \ 135 if(Logging::Guard::IsGuardingFrom(Log::EVERYTHING)) \ 136 { \ 137 guard.reset(new Logging::Guard(Log::EVERYTHING)); \ 138 } \ 139 \ 124 140 OPTIONAL_DO_BACKTRACE \ 125 141 BOX_WARNING("Exception thrown: " \ -
box/trunk/lib/common/Logging.cpp
r3021 r3074 46 46 Logging Logging::sGlobalLogging; //automatic initialisation 47 47 std::string Logging::sProgramName; 48 49 int Logging::Guard::sGuardCount = 0; 50 Log::Level Logging::Guard::sOriginalLevel = Log::INVALID; 48 51 49 52 Logging::Logging() -
box/trunk/lib/common/Logging.h
r3064 r3074 304 304 private: 305 305 Log::Level mOldLevel; 306 static int sGuardCount; 307 static Log::Level sOriginalLevel; 306 308 307 309 public: … … 309 311 { 310 312 mOldLevel = Logging::GetGlobalLevel(); 313 if(sGuardCount == 0) 314 { 315 sOriginalLevel = mOldLevel; 316 } 317 sGuardCount++; 311 318 Logging::SetGlobalLevel(newLevel); 312 319 } 313 320 ~Guard() 314 321 { 322 sGuardCount--; 315 323 Logging::SetGlobalLevel(mOldLevel); 324 } 325 326 static bool IsActive() { return (sGuardCount > 0); } 327 static Log::Level GetOriginalLevel() { return sOriginalLevel; } 328 static bool IsGuardingFrom(Log::Level originalLevel) 329 { 330 return IsActive() && 331 (int)sOriginalLevel >= (int)originalLevel; 316 332 } 317 333 };
Note: See TracChangeset
for help on using the changeset viewer.
