Skip to content

Commit cef6bb2

Browse files
committed
print callback logs to std::cerr, add null check to setCallbackSink for the callback param
1 parent ea4039f commit cef6bb2

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

sycl/source/detail/ur.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ ur_code_location_t codeLocationCallback(void *);
7979

8080
void urLoggerCallback([[maybe_unused]] ur_logger_level_t level, const char *msg,
8181
[[maybe_unused]] void *userData) {
82-
std::cout << msg << std::endl;
82+
std::cerr << msg << std::endl;
8383
}
8484

8585
namespace ur {

unified-runtime/source/adapters/cuda/adapter.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urAdapterSetLoggerCallback(
121121
ur_adapter_handle_t, ur_logger_callback_t pfnLoggerCallback,
122122
void *pUserData, ur_logger_level_t level = UR_LOGGER_LEVEL_QUIET) {
123123

124-
ur::cuda::adapter->logger.setCallbackSink(pfnLoggerCallback, pUserData, level);
124+
ur::cuda::adapter->logger.setCallbackSink(pfnLoggerCallback, pUserData,
125+
level);
125126

126127
return UR_RESULT_SUCCESS;
127128
}

unified-runtime/source/adapters/level_zero/ur_interface_loader.hpp

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

unified-runtime/source/common/logger/ur_logger_details.hpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,16 @@ class Logger {
125125
this->standardSink = std::move(legacySink);
126126
}
127127

128-
void setCallbackSink(ur_logger_callback_t cb, void *pUserData,
128+
void setCallbackSink(ur_logger_callback_t callBack, void *pUserData,
129129
ur_logger_level_t level = UR_LOGGER_LEVEL_QUIET) {
130130
if (!callbackSink) {
131131
callbackSink = std::make_unique<CallbackSink>("UR_LOG_CALLBACK");
132132
}
133-
callbackSinkLevel = level;
134-
callbackSink->setCallback(cb, pUserData);
133+
134+
if (callBack) {
135+
callbackSink->setCallback(callBack, pUserData);
136+
callbackSinkLevel = level;
137+
}
135138
}
136139

137140
void setCallbackLevel(ur_logger_level_t level) {

0 commit comments

Comments
 (0)