-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46 from alephium/log-with-timestamp
Add timestamp to miner log
- Loading branch information
Showing
6 changed files
with
73 additions
and
31 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#ifndef ALEPHIUM_LOG_H | ||
#define ALEPHIUM_LOG_H | ||
|
||
#include <stdio.h> | ||
#include <time.h> | ||
|
||
#ifdef _WIN32 | ||
#define localtime_r(a, b) localtime_s(b, a) | ||
#endif | ||
|
||
#define LOG_TIMESTAMP(stream) \ | ||
{ \ | ||
time_t now = time(NULL); \ | ||
struct tm time; \ | ||
localtime_r(&now, &time); \ | ||
char str[24]; \ | ||
strftime(str, 24, "%Y-%m-%d %H:%M:%S", &time); \ | ||
fprintf(stream, "%s | ", str); \ | ||
} | ||
|
||
#define LOG_WITH_TS(stream, format, ...) \ | ||
{ \ | ||
LOG_TIMESTAMP(stream); \ | ||
fprintf(stream, format, ##__VA_ARGS__); \ | ||
} | ||
|
||
#define LOG_WITHOUT_TS(format, ...) fprintf(stdout, format, ##__VA_ARGS__); | ||
|
||
#define LOG(format, ...) LOG_WITH_TS(stdout, format, ##__VA_ARGS__); | ||
|
||
#define LOGERR(format, ...) LOG_WITH_TS(stderr, format, ##__VA_ARGS__); | ||
|
||
#endif // ALEPHIUM_LOG_H |
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