Skip to content

Commit

Permalink
logger base as string
Browse files Browse the repository at this point in the history
  • Loading branch information
nadrino committed Nov 14, 2024
1 parent f0ba98a commit 7448158
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions include/GenericToolbox.Log.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@
// a very simple logger

// internals
#define GTLogBase __FILE_NAME__ << ":" << __LINE__ << ": "
#define GTLogBase std::string(__FILE_NAME__) + ":" + std::to_string(__LINE__) + ": "

// basics
#define GTLogError std::cout << "ERROR " << GTLogBase
#define GTLogAlert std::cout << "ALERT " << GTLogBase
#define GTLogWarning std::cout << " WARN " << GTLogBase
#define GTLogInfo std::cout << " INFO " << GTLogBase
#define GTLogDebug std::cout << "DEBUG " << GTLogBase
#define GTLogTrace std::cout << "TRACE " << GTLogBase

// conditions
#define GTLogError std::cout << "[ERROR] " << GTLogBase
#define GTLogAlert std::cout << "[ALERT] " << GTLogBase
#define GTLogWarning std::cout << "[ WARN] " << GTLogBase
#define GTLogInfo std::cout << "[ INFO] " << GTLogBase
#define GTLogDebug std::cout << "[DEBUG] " << GTLogBase
#define GTLogTrace std::cout << "[TRACE] " << GTLogBase

// throw
#define GTLogThrow(message_) GTLogError << message_ << std::endl; throw std::runtime_error("exception thrown by the logger.")
#define GTLogThrowIf(condition_, message_) if(condition_){ GTLogThrow( "[" << #condition_ << "] " << message_); }

Expand Down

0 comments on commit 7448158

Please sign in to comment.