Skip to content
This repository has been archived by the owner on Dec 20, 2023. It is now read-only.

Commit

Permalink
Add fileName and lineNumber in WeaveLog*
Browse files Browse the repository at this point in the history
Help debug and identify spammy log
  • Loading branch information
didishe90 committed Jan 14, 2021
1 parent 18d4aef commit 5e5f5c3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
6 changes: 5 additions & 1 deletion src/lib/support/logging/WeaveLogging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,10 @@ static LogMessageFunct gLogFunct = DefaultLogMessage;
* category of the log message. The category
* may be filtered in or out if
* WEAVE_LOG_FILTERING was asserted.
* @param[in] fileName A pointer to a C-formatted, null terminated
* string containing the full path to a file
* @param[in] line A integer expanded from a preprocessor macro
* indicating the line number in a source file
* @param[in] msg A pointer to a NULL-terminated C string with
* C Standard Library-style format specifiers
* containing the log message to be formatted and
Expand All @@ -258,7 +262,7 @@ static LogMessageFunct gLogFunct = DefaultLogMessage;
* correspond to the format specifiers in @a msg.
*
*/
NL_DLL_EXPORT __WEAVE_LOGGING_LINK_ATTRIBUTE void Log(uint8_t module, uint8_t category, const char *msg, ...)
NL_DLL_EXPORT __WEAVE_LOGGING_LINK_ATTRIBUTE void Log(uint8_t module, uint8_t category, const char *fileName, int line, const char *msg, ...)
{
va_list ap;
va_start(ap, msg);
Expand Down
10 changes: 5 additions & 5 deletions src/lib/support/logging/WeaveLogging.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ enum LogCategory
*
*/
#ifndef WeaveLogError
#define WeaveLogError(MOD, MSG, ...) nl::Weave::Logging::Log( nl::Weave::Logging::kLogModule_##MOD , nl::Weave::Logging::kLogCategory_Error, MSG, ## __VA_ARGS__)
#define WeaveLogError(MOD, MSG, ...) nl::Weave::Logging::Log( nl::Weave::Logging::kLogModule_##MOD , nl::Weave::Logging::kLogCategory_Error, __FILE__, __LINE__, MSG, ## __VA_ARGS__)
#endif
#else
#define WeaveLogError(MOD, MSG, ...)
Expand All @@ -230,7 +230,7 @@ enum LogCategory
*
*/
#ifndef WeaveLogProgress
#define WeaveLogProgress(MOD, MSG, ...) nl::Weave::Logging::Log( nl::Weave::Logging::kLogModule_##MOD , nl::Weave::Logging::kLogCategory_Progress, MSG, ## __VA_ARGS__)
#define WeaveLogProgress(MOD, MSG, ...) nl::Weave::Logging::Log( nl::Weave::Logging::kLogModule_##MOD , nl::Weave::Logging::kLogCategory_Progress, __FILE__, __LINE__, MSG, ## __VA_ARGS__)
#endif
#else
#define WeaveLogProgress(MOD, MSG, ...)
Expand All @@ -251,7 +251,7 @@ enum LogCategory
*
*/
#ifndef WeaveLogDetail
#define WeaveLogDetail(MOD, MSG, ...) nl::Weave::Logging::Log( nl::Weave::Logging::kLogModule_##MOD , nl::Weave::Logging::kLogCategory_Detail, MSG, ## __VA_ARGS__)
#define WeaveLogDetail(MOD, MSG, ...) nl::Weave::Logging::Log( nl::Weave::Logging::kLogModule_##MOD , nl::Weave::Logging::kLogCategory_Detail, __FILE__, __LINE__, MSG, ## __VA_ARGS__)
#endif
#else
#define WeaveLogDetail(MOD, MSG, ...)
Expand All @@ -273,7 +273,7 @@ enum LogCategory
*
*/
#ifndef WeaveLogRetain
#define WeaveLogRetain(MOD, MSG, ...) nl::Weave::Logging::Log( nl::Weave::Logging::kLogModule_##MOD , nl::Weave::Logging::kLogCategory_Retain, MSG, ## __VA_ARGS__)
#define WeaveLogRetain(MOD, MSG, ...) nl::Weave::Logging::Log( nl::Weave::Logging::kLogModule_##MOD , nl::Weave::Logging::kLogCategory_Retain, __FILE__, __LINE__, MSG, ## __VA_ARGS__)
#endif

#else // #if WEAVE_RETAIN_LOGGING
Expand Down Expand Up @@ -308,7 +308,7 @@ extern void GetMessageWithPrefix(char *buf, uint8_t bufSize, uint8_t module, con
extern void GetModuleName(char *buf, uint8_t module);
extern void GetCategoryName(char *buf, uint8_t bufSize, uint8_t category);
extern void PrintMessagePrefix(uint8_t module);
extern void Log(uint8_t module, uint8_t category, const char *msg, ...);
extern void Log(uint8_t module, uint8_t category, const char *fileName, int lineNumber, const char *msg, ...);
extern uint8_t GetLogFilter(void);
extern void SetLogFilter(uint8_t category);

Expand Down

0 comments on commit 5e5f5c3

Please sign in to comment.