You must manually acquire the logging mutex before calling this. This will set g_logginglevel, g_initialized, g_loggingOverride
| 30 | // You must manually acquire the logging mutex before calling this. |
| 31 | // This will set g_logginglevel, g_initialized, g_loggingOverride |
| 32 | void InitLogging() |
| 33 | { |
| 34 | if(g_initialized) return; |
| 35 | |
| 36 | g_initialized = true; |
| 37 | |
| 38 | std::string levelstr; |
| 39 | Platform::Getenv(OCIO_LOGGING_LEVEL_ENVVAR, levelstr); |
| 40 | if(!levelstr.empty()) |
| 41 | { |
| 42 | g_loggingOverride = true; |
| 43 | g_logginglevel = LoggingLevelFromString(levelstr.c_str()); |
| 44 | |
| 45 | if(g_logginglevel == LOGGING_LEVEL_UNKNOWN) |
| 46 | { |
| 47 | std::cerr << "[OpenColorIO Warning]: Invalid $OCIO_LOGGING_LEVEL specified. "; |
| 48 | std::cerr << "Options: none (0), warning (1), info (2), debug (3)" << std::endl; |
| 49 | g_logginglevel = LOGGING_LEVEL_DEFAULT; |
| 50 | } |
| 51 | } |
| 52 | else |
| 53 | { |
| 54 | g_logginglevel = LOGGING_LEVEL_DEFAULT; |
| 55 | } |
| 56 | |
| 57 | if (g_logginglevel == LOGGING_LEVEL_DEBUG) |
| 58 | { |
| 59 | std::cerr << "[OpenColorIO Debug]: Using OpenColorIO version: " |
| 60 | << GetVersion() << "\n"; |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | // That's the default logging function. |
| 65 | void DefaultLoggingFunction(const char * message) |
no test coverage detected