42 #include <log4cxx/basicconfigurator.h> 43 #include <log4cxx/consoleappender.h> 44 #include <log4cxx/helpers/bytearrayinputstream.h> 45 #include <log4cxx/patternlayout.h> 46 #include <log4cxx/propertyconfigurator.h> 47 #include <log4cxx/xml/domconfigurator.h> 55 #define MAX_LOG_MSG_LEN 1024 60 const char configEnv[] =
"LSST_LOG_CONFIG";
63 const char layoutPattern[] =
"%c %p: %m%n";
76 if (dotpos != std::string::npos && filename.
compare(dotpos, std::string::npos,
".xml") == 0) {
94 void defaultConfig() {
96 if (
const char* env = getenv(::configEnv)) {
97 if (env[0] and access(env, R_OK) == 0) {
104 log4cxx::LogString pattern(layoutPattern);
105 log4cxx::LayoutPtr layout(
new log4cxx::PatternLayout(pattern));
106 log4cxx::AppenderPtr appender(
new log4cxx::ConsoleAppender(layout));
107 auto root = log4cxx::Logger::getRootLogger();
108 root->addAppender(appender);
116 bool initialized =
false;
122 log4cxx::LoggerPtr log4cxxInit() {
132 return log4cxx::Logger::getRootLogger();
143 pthread_key_create(&
key,
nullptr);
160 log4cxx::LoggerPtr
const& Log::_defaultLogger() {
163 static log4cxx::LoggerPtr _default(::log4cxxInit());
181 ::initialized =
true;
185 log4cxx::BasicConfigurator::resetConfiguration();
205 ::initialized =
true;
209 log4cxx::BasicConfigurator::resetConfiguration();
211 ::configFromFile(filename);
224 ::initialized =
true;
228 log4cxx::BasicConfigurator::resetConfiguration();
231 log4cxx::helpers::InputStreamPtr inStream(
new log4cxx::helpers::ByteArrayInputStream(
data));
232 log4cxx::helpers::Properties prop;
242 if (name ==
"root") {
257 if (loggername.
empty()){
277 log4cxx::MDC::remove(key);
278 log4cxx::MDC::put(key, value);
286 log4cxx::MDC::remove(key);
298 ::mdcInitFunctions.push_back(
std::move(
function));
309 _logger->setLevel(log4cxx::Level::toLevel(level));
316 log4cxx::LevelPtr level = _logger->getLevel();
319 levelno = level->toInt();
331 if (_logger->isEnabledFor(log4cxx::Level::toLevel(level))) {
354 if (pos == std::string::npos) {
360 name = suffix.
substr(pos);
363 name += suffix.
substr(pos);
372 log4cxx::spi::LocationInfo
const& location,
380 logMsg(level, location, msg);
385 void Log::logMsg(log4cxx::LevelPtr level,
386 log4cxx::spi::LocationInfo
const& location,
392 void *
ptr = pthread_getspecific(::pthreadKey.key);
393 if (ptr ==
nullptr) {
396 ptr =
static_cast<void*
>(&::pthreadKey);
397 pthread_setspecific(::pthreadKey.key, ptr);
401 for (
auto& fun: mdcInitFunctions) {
407 _logger->forcedLog(level, msg, location);
T find_first_not_of(T... args)
This static class includes a variety of methods for interacting with the the logging module...
def MDCRegisterInit(func)
LSST DM logging module built on log4cxx.
T find_last_of(T... args)
A base class for image defects.
def setLevel(loggername, level)
unsigned lwpID()
Function which returns LWP ID on platforms which support it.
def isEnabledFor(logger, level)
def configure_prop(properties)
def getLogger(loggername)