Skip to content

Commit

Permalink
Merge pull request #105 from ela34/logredirect
Browse files Browse the repository at this point in the history
Add a mechanism trough configuration to allow redirecting logs
  • Loading branch information
sepfy authored Aug 29, 2024
2 parents 03057f7 + 219c885 commit ff900a9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@
#define IFR_NAME "w"

//#define LOG_LEVEL LEVEL_DEBUG
#define LOG_REDIRECT 0

#endif // CONFIG_H_
6 changes: 6 additions & 0 deletions src/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,14 @@
#define LOG_LEVEL LEVEL_INFO
#endif

#if LOG_REDIRECT
void peer_log(char *level_tag, const char *file_name, int line_number, const char *fmt, ...);
#define LOG_PRINT(level_tag, fmt, ...) \
peer_log(level_tag, __FILE__, __LINE__, fmt, ##__VA_ARGS__)
#else
#define LOG_PRINT(level_tag, fmt, ...) \
fprintf(stdout, "%s\t%s\t%d\t" fmt"\n", level_tag, __FILE__, __LINE__, ##__VA_ARGS__)
#endif

#if LOG_LEVEL >= LEVEL_DEBUG
#define LOGD(fmt, ...) LOG_PRINT(DEBUG_TAG, fmt, ##__VA_ARGS__)
Expand Down

0 comments on commit ff900a9

Please sign in to comment.