diff --git a/cscore.def b/cscore.def index 6e487f87c2..808e9ccb54 100644 --- a/cscore.def +++ b/cscore.def @@ -84,3 +84,4 @@ CS_SetCameraWhiteBalanceManual @81 CS_SetCameraExposureAuto @82 CS_SetCameraExposureHoldCurrent @83 CS_SetCameraExposureManual @84 +CS_SetDefaultLogger @85 diff --git a/include/cscore_c.h b/include/cscore_c.h index c75d3cc7f7..c788182c39 100644 --- a/include/cscore_c.h +++ b/include/cscore_c.h @@ -345,6 +345,7 @@ int CS_NotifierDestroyed(void); typedef void (*CS_LogFunc)(unsigned int level, const char* file, unsigned int line, const char* msg); void CS_SetLogger(CS_LogFunc func, unsigned int min_level); +void CS_SetDefaultLogger(unsigned int min_level); // // Utility Functions diff --git a/include/cscore_cpp.h b/include/cscore_cpp.h index 5ede8d6b98..89bcbb9c2d 100644 --- a/include/cscore_cpp.h +++ b/include/cscore_cpp.h @@ -311,6 +311,7 @@ typedef std::function LogFunc; void SetLogger(LogFunc func, unsigned int min_level); +void SetDefaultLogger(unsigned int min_level); // // Utility Functions diff --git a/src/Log.cpp b/src/Log.cpp index 271d1ffc07..ea46a30858 100644 --- a/src/Log.cpp +++ b/src/Log.cpp @@ -61,6 +61,8 @@ static void def_log_func(unsigned int level, const char* file, #endif } -Logger::Logger() { SetLogger(def_log_func); } +Logger::Logger() { SetDefaultLogger(); } Logger::~Logger() {} + +void Logger::SetDefaultLogger() { SetLogger(def_log_func); } diff --git a/src/Log.h b/src/Log.h index 830600e713..744ee13733 100644 --- a/src/Log.h +++ b/src/Log.h @@ -21,6 +21,8 @@ class Logger : public wpi::Logger { } ~Logger(); + void SetDefaultLogger(); + private: Logger(); diff --git a/src/cscore_c.cpp b/src/cscore_c.cpp index 95d4badf38..f957e0a769 100644 --- a/src/cscore_c.cpp +++ b/src/cscore_c.cpp @@ -299,6 +299,10 @@ void CS_SetLogger(CS_LogFunc func, unsigned int min_level) { cs::SetLogger(func, min_level); } +void CS_SetDefaultLogger(unsigned int min_level) { + cs::SetDefaultLogger(min_level); +} + CS_Source* CS_EnumerateSources(int* count, CS_Status* status) { llvm::SmallVector buf; auto handles = cs::EnumerateSourceHandles(buf, status); diff --git a/src/cscore_cpp.cpp b/src/cscore_cpp.cpp index ae78fc4296..3fccd68de0 100644 --- a/src/cscore_cpp.cpp +++ b/src/cscore_cpp.cpp @@ -592,6 +592,12 @@ void SetLogger(LogFunc func, unsigned int min_level) { logger.set_min_level(min_level); } +void SetDefaultLogger(unsigned int min_level) { + Logger& logger = Logger::GetInstance(); + logger.SetDefaultLogger(); + logger.set_min_level(min_level); +} + // // Utility Functions //