diff options
author | Pau Espin Pedrol <pespin@sysmocom.de> | 2018-04-25 16:43:02 +0200 |
---|---|---|
committer | Pau Espin Pedrol <pespin@sysmocom.de> | 2018-04-25 16:45:34 +0200 |
commit | 3b78cbfdc16ef67f53e1e5ac8b94257ba81b0795 (patch) | |
tree | 21c8c80996a2ee586da37e16d29efa9a44b228f2 /CommonLibs/Logger.h | |
parent | f3d7f443a01e2a021a32cdbb402a38fdcedd2fee (diff) |
Logger: Print correct source file and line number
Before this commit, always Logger.cpp:53 was being printed.
Change-Id: Ie5c64b4961c7c41d23484784a93eda5e08331f08
Diffstat (limited to 'CommonLibs/Logger.h')
-rw-r--r-- | CommonLibs/Logger.h | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/CommonLibs/Logger.h b/CommonLibs/Logger.h index 00efcd7..5b0b05c 100644 --- a/CommonLibs/Logger.h +++ b/CommonLibs/Logger.h @@ -48,10 +48,10 @@ extern "C" { #endif #define LOG(level) \ - Log(DMAIN, LOGL_##level).get() << "[tid=" << pthread_self() << "] " + Log(DMAIN, LOGL_##level, __BASE_FILE__, __LINE__).get() << "[tid=" << pthread_self() << "] " #define LOGC(category, level) \ - Log(category, LOGL_##level).get() << "[tid=" << pthread_self() << "] " + Log(category, LOGL_##level, __BASE_FILE__, __LINE__).get() << "[tid=" << pthread_self() << "] " /** A C++ stream-based thread-safe logger. @@ -67,11 +67,14 @@ class Log { std::ostringstream mStream; ///< This is where we buffer up the log entry. int mCategory; ///< Priority of current report. int mPriority; ///< Category of current report. + const char *filename; ///< Source File Name of current report. + int line; ///< Line number in source file of current report. public: - Log(int wCategory, int wPriority) - : mCategory(wCategory), mPriority(wPriority) + Log(int wCategory, int wPriority, const char* filename, int line) + : mCategory(wCategory), mPriority(wPriority), + filename(filename), line(line) { } // Most of the work is in the destructor. |