This repository has been archived by the owner on Jun 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added EVHTP_DEBUG option (with new logging)
- Passing 'cmake -DEVHTP_DEBUG:STRING=ON' to cmake enables verbose debug logging. - Added log.h, simple pretty-logger.
- Loading branch information
1 parent
aa8a989
commit f20e5cf
Showing
6 changed files
with
87 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#pragma once | ||
|
||
#include <stdio.h> | ||
#include <errno.h> | ||
#include <string.h> | ||
|
||
#define __FILENAME__ \ | ||
(strrchr(__FILE__, '/') ? \ | ||
strrchr(__FILE__, '/') + 1 : __FILE__) | ||
|
||
#define clean_errno() \ | ||
(errno == 0 ? "None" : strerror(errno)) | ||
|
||
|
||
#if !defined(EVHTP_DEBUG) | ||
/* compile with all debug messages removed */ | ||
#define log_debug(M, ...) | ||
#else | ||
#define log_debug(M, ...) \ | ||
fprintf(stderr, "\33[34mDEBUG\33[39m "M " \33[90m at %s (%s:%d) \33[39m\n", ## \ | ||
__VA_ARGS__, \ | ||
__func__, \ | ||
__FILE__, \ | ||
__LINE__) | ||
#endif | ||
|
||
|
||
#define log_error(M, ...) \ | ||
fprintf(stderr, "\33[31mERR\33[39m " M " \33[90m at %s (%s:%d) \33[94merrno: %s\33[39m\n", ## \ | ||
__VA_ARGS__, \ | ||
__func__, \ | ||
__FILE__, \ | ||
__LINE__, \ | ||
clean_errno()) | ||
|
||
#define log_warn(M, ...) \ | ||
fprintf(stderr, "\33[91mWARN\33[39m " M " \33[90m at %s (%s:%d) \33[94merrno: %s\33[39m\n", ## \ | ||
__VA_ARGS__, \ | ||
__func__, \ | ||
__FILE__, \ | ||
__LINE__, \ | ||
clean_errno()) | ||
|
||
#define log_info(M, ...) \ | ||
fprintf(stderr, "\33[32mINFO\33[39m " M " \33[90m at %s (%s:%d) \33[39m\n", ## \ | ||
__VA_ARGS__, \ | ||
__func__, \ | ||
__FILENAME__, \ | ||
__LINE__) |
Oops, something went wrong.