示例#1
0
void Setup::configure(std::string s)
{
  auto pos = s.find('=');
  if(pos == std::string::npos) {
    setDefaultLevel(stringToLevel(s));
  } else {
    setLevel(s.substr(0, pos), stringToLevel(s.substr(pos+1)));
  }
}
SyslogLogger::SyslogLogger(ComponentContext *context) : Component(context) {
    const Config *config = context->getConfig();
	const std::string componentXPath = context->getComponentXPath();
/*
	std::string globalLogIdent = config->asString("/fastcgi/daemon/global-log-ident");
	const int facility = config->asInt(componentXPath + "/facility", 0);
	if (facility < 0 || facility > 6) {
		throw std::runtime_error("SyslogLogger: facility must be in range 0..6");
	}
	openlog(globalLogIdent.c_str(), 0, facility);
*/
	ident_ = config->asString(componentXPath + "/ident");
					    
	setLevel(stringToLevel(config->asString(componentXPath + "/level")));
}
void SyslogLogger::handleRequest(Request *request, HandlerContext *handlerContext) {
    request->setContentType("text/plain");
    const std::string &action = request->getArg("action");
    if ("setlevel" == action) {
        const std::string &l = request->getArg("level");
        setLevel(stringToLevel(l));
        RequestStream(request) << "level " << l << "successfully set" << std::endl;
    }
    else if ("rollover" == action) {
        rollOver();
        RequestStream(request) << "rollover successful" << std::endl;
    }
    else {
        RequestStream(request) << "bad action" << std::endl;
    }
}
示例#4
0
DefaultLogger::DefaultLogger(ComponentContext *context) 
	: Component(context), logger_(log4cxx::Logger::getRootLogger())
{
	const Config *config = context->getConfig();
	const std::string componentXPath = context->getComponentXPath();

	std::string layoutPattern = config->asString(componentXPath + "/pattern", "DEFAULT");

    log4cxx::LayoutPtr layout(new log4cxx::PatternLayout(
				"DEFAULT" == layoutPattern ? log4cxx::PatternLayout::TTCC_CONVERSION_PATTERN : layoutPattern));

    logger_ = log4cxx::Logger::getLogger(config->asString(componentXPath + "/ident"));

	const std::string logFileName = config->asString(componentXPath + "/file");
    appender_ = log4cxx::helpers::ObjectPtrT<log4cxx::RollingFileAppender>(new log4cxx::RollingFileAppender(layout, logFileName));

    appender_->setMaxFileSize("2000MB");

    logger_->addAppender(appender_);

    setLevel(stringToLevel(config->asString(componentXPath + "/level")));	
}
示例#5
0
文件: AuditLog.cpp 项目: pohly/cynara
void AuditLog::init(void) {
    char *env_val = getenv("CYNARA_AUDIT_LEVEL");
    if (env_val) {
        m_logLevel = stringToLevel(env_val);
    }
}
示例#6
0
文件: logging.cpp 项目: 2510/xtreemfs
void initialize_logger(std::string stringLevel,
                       std::string logfilePath,
                       LogLevel defaultLevel) {
  initialize_logger(stringToLevel(stringLevel, defaultLevel), logfilePath);
}