-
Notifications
You must be signed in to change notification settings - Fork 5.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Logging level #38
Logging level #38
Changes from 1 commit
94b99a0
a80f2ee
4e88f52
2478ed7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,20 +11,42 @@ | |
|
||
#include "utarray.h" | ||
|
||
#ifndef RAY_COMMON_DEBUG | ||
#define RAY_COMMON_DEBUG 0 | ||
#define RAY_COMMON_INFO 1 | ||
#define RAY_COMMON_WARNING 2 | ||
#define RAY_COMMON_ERROR 3 | ||
#define RAY_COMMON_FATAL 4 | ||
|
||
/* Default logging level is INFO. */ | ||
#ifndef RAY_COMMON_LOG_LEVEL | ||
#define RAY_COMMON_LOG_LEVEL RAY_COMMON_INFO | ||
#endif | ||
|
||
#if (RAY_COMMON_LOG_LEVEL > RAY_COMMON_DEBUG) | ||
#define LOG_DEBUG(M, ...) | ||
#else | ||
#define LOG_DEBUG(M, ...) \ | ||
fprintf(stderr, "[DEBUG] (%s:%d) " M "\n", __FILE__, __LINE__, ##__VA_ARGS__) | ||
#endif | ||
|
||
#define LOG_ERR(M, ...) \ | ||
fprintf(stderr, "[ERROR] (%s:%d: errno: %s) " M "\n", __FILE__, __LINE__, \ | ||
errno == 0 ? "None" : strerror(errno), ##__VA_ARGS__) | ||
|
||
#if (RAY_COMMON_LOG_LEVEL > RAY_COMMON_INFO) | ||
#define LOG_INFO(M, ...) | ||
#else | ||
#define LOG_INFO(M, ...) \ | ||
fprintf(stderr, "[INFO] (%s:%d) " M "\n", __FILE__, __LINE__, ##__VA_ARGS__) | ||
#endif | ||
|
||
#if (RAY_COMMON_LOG_LEVEL > RAY_COMMON_ERROR) | ||
#define LOG_ERROR(M, ...) | ||
#else | ||
#define LOG_ERROR(M, ...) \ | ||
fprintf(stderr, "[ERROR] (%s:%d: errno: %s) " M "\n", __FILE__, __LINE__, \ | ||
errno == 0 ? "None" : strerror(errno), ##__VA_ARGS__) | ||
#endif | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. may have introduced some compiler warnings.
|
||
|
||
#if (RAY_COMMON_LOG_LEVEL > RAY_COMMON_FATAL) | ||
#define LOG_FATAL(M, ...) | ||
#else | ||
#define LOG_FATAL(M, ...) \ | ||
do { \ | ||
fprintf(stderr, "[FATAL] (%s:%d) " M "\n", __FILE__, __LINE__, \ | ||
|
@@ -34,10 +56,11 @@ | |
backtrace_symbols_fd(buffer, calls, 1); \ | ||
exit(-1); \ | ||
} while (0); | ||
#endif | ||
|
||
#define CHECKM(COND, M, ...) \ | ||
if (!(COND)) { \ | ||
LOG_ERR("Check failure: %s \n" M, #COND, ##__VA_ARGS__); \ | ||
#define CHECKM(COND, M, ...) \ | ||
if (!(COND)) { \ | ||
LOG_ERROR("Check failure: %s \n" M, #COND, ##__VA_ARGS__); \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That said, do we actually want LOG_WARN, LOG_ERROR, and LOG_FATAL? It seems like either we can recover, in which case it should be LOG_WARN, or we can't, in which case it should be LOG_FATAL. I think pretty much all of the LOG_ERRORs that we currently have should potentially be fatal errors. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, I was just following standard logging levels found in other systems here. I think it makes sense to differentiate between LOG_WARN and LOG_ERROR. Here is a good post that talks about the different levels: link. I'll look through the LOG_ERRORs and see which ones might need to be LOG_FATAL. |
||
} | ||
|
||
#define CHECK(COND) CHECKM(COND, "") | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ BUILD = build | |
all: $(BUILD)/plasma_store $(BUILD)/plasma_manager $(BUILD)/plasma_client.so $(BUILD)/example $(BUILD)/libplasma_client.a | ||
|
||
debug: FORCE | ||
debug: CFLAGS += -DRAY_COMMON_DEBUG=1 | ||
debug: CFLAGS += -DRAY_COMMON_LOG_LEVEL=0 | ||
debug: all | ||
|
||
clean: | ||
|
@@ -35,8 +35,8 @@ common: FORCE | |
git submodule update --init --recursive | ||
cd ../common; make | ||
|
||
# Set the request timeout low for testing purposes. | ||
test: CFLAGS += -DRAY_TIMEOUT=50 | ||
# Set the request timeout low and logging level at FATAL for testing purposes. | ||
test: CFLAGS += -DRAY_TIMEOUT=50 -DRAY_COMMON_LOG_LEVEL=4 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if we keep the ERROR level, then maybe this should be ERROR. If not, the FATAL is good. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wanted to keep the level at FATAL because some of the tests test error scenarios, which is why we have so many log messages right now. |
||
# First, build and run all the unit tests. | ||
test: $(BUILD)/manager_tests FORCE | ||
./build/manager_tests | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just tried running
And it printed
If that is something that happens normally while Ray is functioning correctly, then there it shouldn't be an error or even a warning. It should be INFO or DEBUG, right?