예제 #1
0
bool    cmd_set_log_level(vty_t* vty, variant_stack_t* params)
{
    const char* log_class = variant_get_string(stack_peek_at(params, 2));
    const char* log_level = variant_get_string(stack_peek_at(params, 3));

    int service_id;

    for(int i = 0; i < logger_services_size; i++)
    {
        logger_service_t* s = *(logger_services + i);
        if(strcmp(s->service_name, log_class) == 0)
        {
            service_id = s->service_id;
            break;
        }
    }

    if(strcmp(log_level, "info") == 0)
    {
        logger_set_level(service_id, LOG_LEVEL_BASIC);
    }
    else if(strcmp(log_level, "error") == 0)
    {
        logger_set_level(service_id, LOG_LEVEL_ERROR);
    }
    else if(strcmp(log_level, "advanced") == 0)
    {
        logger_set_level(service_id, LOG_LEVEL_ADVANCED);
    }
    else if(strcmp(log_level, "debug") == 0)
    {
        logger_set_level(service_id, LOG_LEVEL_DEBUG);
    }
}
예제 #2
0
파일: main.c 프로젝트: bmoscon/Rogue
int main(int argc, char* argv[])
{
    state_st state = {0};
  
    // set locale, otherwise we cant use unicode characters for the walls
    setlocale(LC_ALL, "");

    // seed random #
    srand(time(NULL));

    // check for logging
    if (argc > 1) {
	if (!strcmp(argv[1], "--debug")) {
	    logger_set_level(LOGGER_LEVEL_DEBUG);
	} else if (!strcmp(argv[1], "--verbose")) {
	    logger_set_level(LOGGER_LEVEL_VERBOSE);
	} else if (!strcmp(argv[1], "--warn")) {
	    logger_set_level(LOGGER_LEVEL_WARN);
	} else if (!strcmp(argv[1], "--error")) {
	    logger_set_level(LOGGER_LEVEL_ERROR);
	}
    }

    // set up logger. If no level has been set this call will do nothing. 
    logger_init();
    
    // set up game state
    game_init(&state);

    // welcome screen. get rogue's name, roll rogue
    welcome(&state);

    // game loop
    do {
	
        // draw
	draw(&state);
    
	// input
	input_handler(&state);
    
    } while(state.running);
 
    endwin();
  
    free_state(&state);
    logger_stop();
    return (EXIT_SUCCESS);
}
예제 #3
0
파일: logger.c 프로젝트: tubav/impd4e
/**
 * Initialize logger
 */
void logger_init( int level ){
   // TODO support file
   logger_model.fp=NULL;
   //   logger_model.time_fmt="%m-%d-%Y %T.";
   logger_model.time_fmt="%T.";
   logger_set_level(level);
}
예제 #4
0
파일: raop.c 프로젝트: mk01/shairplay
void
raop_set_log_level(raop_t *raop, int level)
{
    assert(raop);

    logger_set_level(raop->logger, level);
}
예제 #5
0
int main(int argc, char **argv)
{
	logger_t *lg_test;
	lg_test = logger_init();
	logger_set_level (lg_test, LOGGER_DEBUG);
	logger_set_callback(lg_test, cb, NULL);

	logger_log(lg_test, LOGGER_DEBUG, "test %s", "Hello world\n" );
	return 0;
}
예제 #6
0
파일: fix-db.c 프로젝트: NUOG/ejudge
int
main(int argc, char *argv[])
{
  program_name = os_GetBasename(argv[0]);
  logger_set_level(-1, LOG_WARNING);

  if (argc < 1) die("not enough parameters");

  if (argc == 2) {
    if (!strcmp(argv[1], "--help")) {
      write_help();
    } else if (!strcmp(argv[1], "--version")) {
      write_version();
    }
  }

#if defined EJUDGE_XML_PATH
  if (!ejudge_xml_path) ejudge_xml_path = EJUDGE_XML_PATH;
#endif /* EJUDGE_XML_PATH */
  if (!ejudge_xml_path) die("ejudge.xml path is not specified");
  if (!(ejudge_config = ejudge_cfg_parse(ejudge_xml_path, 1))) return 1;
  if (!ejudge_config->contests_dir) die("<contests_dir> tag is not set!");
  if (contests_set_directory(ejudge_config->contests_dir) < 0)
    die("contests directory is invalid");

  load_mysql_plugin();

  /* consult the main compilation configuration */
  compile_cfg_path[0] = 0;
  if (ejudge_config->compile_home_dir) {
    snprintf(compile_cfg_path, sizeof(compile_cfg_path), "%s/conf/compile.cfg",
             ejudge_config->compile_home_dir);
  }
  if (!compile_cfg_path[0] && ejudge_config->contests_home_dir) {
    snprintf(compile_cfg_path, sizeof(compile_cfg_path), "%s/compile/conf/compile.cfg",
             ejudge_config->contests_home_dir);
  }
#if defined EJUDGE_CONTESTS_HOME_DIR
  if (!compile_cfg_path[0]) {
    snprintf(compile_cfg_path, sizeof(compile_cfg_path), "%s/compile/conf/compile.cfg",
             EJUDGE_CONTESTS_HOME_DIR);
  }
#endif

  cs_config = prepare_parse_config_file(compile_cfg_path, 0);
  if (!cs_config) {
    die("failed to parse compilation configuration file %s", compile_cfg_path);
  }
  handle_cs_config();

  process_all_contests();

  return 0;
}
예제 #7
0
/*!
 * @brief Set logging level for main_logger
 * @param sig SIGUSR1 for DEBUGs, SIGUSR2 for INFOs
 */
static void logger_handle_usr_signal(int sig) {
    logger_cpp::Level level;
    for (auto logger: logger_cpp::LoggerFactory::instance().get_loggers()) {
        switch (sig) {
            case SIGUSR1:
                level = logger_cpp::Level::DEBUG;
                break;
            case SIGUSR2:
                level = logger->get_options().get_default_level();
                break;
            default:
                return;
        }
        logger_set_level(logger->get_instance(), static_cast<unsigned>(level));
    }
}