Esempio n. 1
0
int main(int argc, char *argv[])
{
    (void) argc;
    (void) argv;
    
    struct log *l;

    l = log_new("/tmp/log_test.txt", LOG_ALL);

    assert(l);
    
    log_clear(l);
    
    log_set_level(l, LOG_INFO);
    log_debug(l, "module-1", "debug message\n");

    log_set_level(l, LOG_DEBUG);
    log_debug(l, "module-1", "debug message\n");
    
    log_info(l, "module-2", "info message\n");
    log_warning(l, NULL, "warning message\n");
    log_error(l, "module-1","error message\n");

    log_printf(l, LOG_WARNING, "module-3", "more warnings - ");
    log_append(l, "%s\n", "\"this string is appended\"");
    
    fprintf(stdout, "log_print():\n");
    log_print(l, STDOUT_FILENO);
    
    log_delete(l);
    
    return 0;
}
/**
 * Runs the test cases for the logging system.
 * @return 
 */
int logging_system_tests() {
    
    puts("**********************************************************");
    puts("****           Running logging system tests           ****");
    puts("**********************************************************");
    puts("");

    puts("TEST CASE 1: ");
    int level = log_log(LOG_DEBUG, "\tdebug");
    if (level == 0)
        printf("OK\n");
    else {
        printf("FAILED! Expected no output with logging system uninitialized but log_write_log returned %d\n", level);
        return EXIT_FAILURE;
    }
        
    log_set_level(LOG_DEBUG);
    puts("TEST CASE 2: ");
    level = log_log(LOG_DEBUG, "test message debug");
    if (level == LOG_DEBUG)
        printf("OK\n");
    else {
        printf("FAILED! Expected DEBUG but log_write_log returned %d\n", level);
        return EXIT_FAILURE;
    }
    
    log_set_level(LOG_INFO);
    
    level = log_log(LOG_INFO, "test message info");
    puts("TEST CASE 3: ");
    if (level == LOG_INFO)
        printf("OK\n");
    else {
        printf("FAILED! Expected INFO but log_write_log returned %d\n", level);
        return EXIT_FAILURE;
    }
    
    puts("TEST CASE 4: ");
    level = log_log(LOG_DEBUG, "test message debug");
    if (level == 0)
        printf("OK\n");
    else {
        printf("FAILED! Expected no output but log_write_log returned %d\n", level);
        return EXIT_FAILURE;
    }
    
    level = log_log(LOG_ERROR, "test message error");
    puts("TEST CASE 5: ");
    if (level == LOG_ERROR)
        printf("OK\n");
    else {
        printf("FAILED! Expected ERROR but log_write_log returned %d\n", level);
        return EXIT_FAILURE;
    }
    
    return EXIT_SUCCESS;
    
}
Esempio n. 3
0
int main(void)
{
    int count = 100000;
    log_set_file("/var/va_server/test.log");
    log_set_level(LOG_LEVEL_DEBUG);

    if(fork() > 0){
        while(count-- > 0){
            log_debug("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
            log_info("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
            log_warn("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
            log_error("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
        }
        log_close();
    }
    else{
        while(count-- > 0){
            log_debug("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
            log_info("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
            log_warn("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
            log_error("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
        }
        log_close();
    }

    return 1;
}
Esempio n. 4
0
int do_loglevel(int nargs, char **args) {
    if (nargs == 2) {
        log_set_level(atoi(args[1]));
        return 0;
    }
    return -1;
}
int main(void) 
{
    int sock_fd = -1;
    char buffer[1024];
    int bytes_recv = -1;
    
    log_set_level(LOG_LEVEL_DEBUG);

    sock_fd = udp_unix_socket_create(UNIX_DOMAIN_PATH);
    if (sock_fd < 0) {
        log_error("udp_unix_socket_create failed.");
        return 0;
    }

    set_non_blocking(sock_fd); 
    while(1) {
        bzero(buffer, sizeof(buffer));
        bytes_recv = udp_unix_socket_recv(sock_fd, buffer, sizeof(buffer) - 1);
        if (bytes_recv > 0) {
            log_debug("%d %s", bytes_recv, buffer);
        }
        else {
            log_info("no data received.");
        }
    }

    udp_unix_socket_close(sock_fd); 

    return 1;
}
Esempio n. 6
0
void restart_logging (ice_config_t *config)
{
    if (strcmp (config->error_log, "-"))
    {
        char fn_error[FILENAME_MAX];
        snprintf (fn_error, FILENAME_MAX, "%s%s%s", config->log_dir, PATH_SEPARATOR, config->error_log);
        log_set_filename (errorlog, fn_error);
        log_set_level (errorlog, config->loglevel);
        log_set_trigger (errorlog, config->logsize);
        log_set_archive_timestamp(errorlog, config->logarchive);
        log_reopen (errorlog);
    }

    if (strcmp (config->access_log, "-"))
    {
        char fn_error[FILENAME_MAX];
        snprintf (fn_error, FILENAME_MAX, "%s%s%s", config->log_dir, PATH_SEPARATOR, config->access_log);
        log_set_filename (accesslog, fn_error);
        log_set_trigger (accesslog, config->logsize);
        log_set_archive_timestamp (accesslog, config->logarchive);
        log_reopen (accesslog);
    }

    if (config->playlist_log)
    {
        char fn_error[FILENAME_MAX];
        snprintf (fn_error, FILENAME_MAX, "%s%s%s", config->log_dir, PATH_SEPARATOR, config->playlist_log);
        log_set_filename (playlistlog, fn_error);
        log_set_trigger (playlistlog, config->logsize);
        log_set_archive_timestamp (playlistlog, config->logarchive);
        log_reopen (playlistlog);
    }
}
Esempio n. 7
0
File: log.c Progetto: eswartz/emul
static
DECL_SYMBOL_ACTION(command_toggle_logging)
{
	int         level;
	char       *name;
	u32         mask, bit;
	int			idx;

	if (task == csa_READ)
	{
		if (iter >= sizeof(log_src) / sizeof(log_src[0]))
			return 0;
		command_arg_set_string(SYM_ARG_1st, log_src[iter]);
		command_arg_set_num(SYM_ARG_2nd, loglevel[iter]);
		return 1;
	}
	
	command_arg_get_string(SYM_ARG_1st, &name);
	command_arg_get_num(SYM_ARG_2nd, &level);

	if ((mask = lookup_system_name(name)) == 0) {
		logger(LOG_ERROR | LOG_USER, _("Unknown subsystem '%s'\n"), name);
		return 0;
	}

	for (idx = 0, bit = 1; 
		 idx < LOG_NUM_SRC; 
		 idx ++, bit += bit) {
		if (mask & bit) {
			log_set_level(idx, level);
		}
	}

	return 1;
}
Esempio n. 8
0
static void main_loop(int flag, LogLevel_t level, const char *logName)
{
	int cnt = 0;
	DBG("Log Test Start: %d.", cnt++);
	INFO("Info: %d", cnt++);
	ERR("Err: %d", cnt++);
	FILE *fp = fopen("not_exit", "b");
	ERRSTR("Open none exist file");

	LogHandle hLog;

	hLog = log_create(level, flag, logName, 1024 * 1024);
	assert(hLog != NULL);
	
	for(level = LOG_LEVEL_DBG; level < LOG_LEVEL_MAX; level++)
	{
		log_print(hLog, "Log level: %d", level);
		log_set_level(hLog, level);
		
		log_debug(hLog, "Debug info, log name %s", logName);
		log_warning(hLog,"Warning, flag: %u, level: %d", flag, level);
		log_error(hLog,"Error, log handle addr: 0x%X", hLog);
	}

	const char *pErr = str_err((int)E_BUSY);
	printf("Err string: %s\n", pErr);

	log_print(hLog, "Log test success!");
}
Esempio n. 9
0
int main(int argc, char **argv) {
    log_set_level(LOG_WARN);
    test_scheduler_124_8();
    test_scheduler_44_2();
    test_scheduler_2222_4();
    return 0;
}
Esempio n. 10
0
static void parse_arguments(int argc, char **argv)
{
        static const char short_options [] = "hvtDd:l:o:c:";

        static const struct option
                long_options [] = {
                { "help",        no_argument, NULL, 'h' },
                { "version",     no_argument, NULL, 'v' },
                { "directory",   required_argument, NULL, 'd' },
                { "config",      required_argument, NULL, 'c' },
                { "log",         required_argument, NULL, 'l' },
                { "test",        no_argument, NULL, 't' },
                { "debug",       no_argument, NULL, 'D' },
                { "output-file", required_argument, NULL, 'o' },
                { 0, 0, 0, 0 }
        };

        for (;;) {
                int index, c = 0;
                
                c = getopt_long(argc, argv, short_options, long_options, &index);

                if (-1 == c)
                        break;

                switch (c) {
                case 0: /* getopt_long() flag */
                        break;

                case 'h':
                        usage(stdout, argc, argv);
                        exit(EXIT_SUCCESS);
                case 'v':
                        print_version(stdout);
                        exit(EXIT_SUCCESS);
                case 't':
                        _test = 1;
                        break;
                case 'D':
                        log_set_level(LOG_DEBUG);
                        break;
                case 'd':
                        _home_dir = optarg;
                        break;
                case 'c':
                        _config_file = optarg;
                        break;
                case 'l':
                        _log_file = optarg;
                        break;
                case 'o':
                        _output_file = optarg;
                        break;
                default:
                        usage(stderr, argc, argv);
                        exit(EXIT_FAILURE);
                }
        }
}
Esempio n. 11
0
int cli_parse_reset_stats(int argc, char **argv)
{
    int ret = 0;
    int opt;
    int opt_idx = 0;
    uint32_t request_length, reply_length;
    cmdif_request_reset_stats request;
    cmdif_reply_reset_stats reply;

    memset(&request, 0, sizeof(request));
    request.hdr.xid = htonl(UINT32_MAX * rand());
    request.hdr.cmd = CMDIF_CMD_RESET_STATS;
    request.hdr.length = htons(sizeof(request));

    while(1){
        opt = getopt_long(argc, argv, "hv", cli_cmd_rs_options, &opt_idx);
        if(opt == -1){
            break;
        }

        switch(opt){
        case CLI_CMD_RS_TX:
            request.cmd_options = CMDIF_CMD_STATS_OPTS_TX;
            break;
        case CLI_CMD_RS_RX:
            request.cmd_options = CMDIF_CMD_STATS_OPTS_RX;
            break;
        case 'v':
            log_set_level(LOG_DEBUG);
            break;
        case 'h':
        default:
            ret = -1;
            break;
        }
    }

    if(ret < 0){
        cli_print_reset_stats_usage();
        return -1;
    }

    log_debug("request: xid = %u", ntohl(request.hdr.xid));

    request.cmd_options = htons(request.cmd_options);

    request_length = sizeof(request);
    reply_length = sizeof(reply);
    ret = cli_exec_cmd(&request, &request_length,
                       &reply, &reply_length);
    if(ret < 0){
        log_err("cannot execute a command.");
    }

    log_debug("reply: xid = %u, status = %u",
              ntohl(reply.hdr.xid), reply.hdr.status);
    return 0;
}
Esempio n. 12
0
void* thread2(void* v) {
    FILE* flog = v;
    logmsg("I'm thread 2.\n");
    log_set_level(LOG_VERB);
    log_to(flog);
    logmsg("%s\n", STRING2A);
    logverb("%s\n", STRING2B);
    return NULL;
}
Esempio n. 13
0
/*
 * Main program
 */
int main(int argc, char * argv[])
{
    g_type_init();
    g_thread_init(NULL);

    app_init_cmdline(&argc, &argv);

    log_set_level("MCU", app.cmdline.verbose);
    log_set_level("GSM02", app.cmdline.verbose);
    log_set_level("SCRIPT", app.cmdline.verbose);
    log_set_level("SERVICE", app.cmdline.verbose);

    app_start_server();

    g_main_loop_run(g_main_loop_new(NULL, TRUE));

    return (EXIT_SUCCESS);
}
Esempio n. 14
0
void* thread1(void* v) {
    FILE* flog = v;
    logmsg("I'm thread 1.\n");
    log_set_level(LOG_MSG);
    log_to(flog);
    logmsg("%s\n", STRING1A);
    sleep(1);
    logverb("%s\n", STRING1B);
    return NULL;
}
Esempio n. 15
0
void
sim_init(void)
{
  pl_init();

  sim_spacecraft_control_init();

  // Set log level, need to do that here
  const char *levStr = NULL;
  config_get_str_def("openorbit/sys/log-level", &levStr, "info");
  log_set_level(log_get_lev_from_str(levStr));

  // Load and run initialisation script
  scripting_init();

  if (!scripting_run_file("script/init.py")) {
    log_fatal("script/init.py missing");
  }

  sim_init_graphics();

  float freq;
  config_get_float_def("openorbit/sim/freq", &freq, 20.0); // Read in Hz
  gSIM_state.stepSize = 1.0 / freq; // Period in s
  
  // Setup IO-tables, must be done after joystick system has been initialised
  io_init();

  gSIM_state.world = sim_load_world(sim_get_scene(), "data/solsystem.hrml");
  pl_time_set(sim_time_get_jd());


  sim_spacecraft_t *sc = sim_new_spacecraft("Mercury", "Mercury I");
  sim_spacecraft_set_sys_and_coords(sc, "Earth",
                      0.0 /*longitude*/,
                      0.0 /*latitude*/,
                      250.0e3 /*altitude*/);
  sim_set_spacecraft(sc);

  sg_camera_t *cam = sg_scene_get_cam(sc->scene);
  sim_stage_t *stage = ARRAY_ELEM(sc->stages, 1);
  sg_camera_track_object(cam, stage->sgobj);
  sg_camera_follow_object(cam, stage->sgobj);
  sg_camera_set_follow_offset(cam, vd3_set(0.0, 0.0, -150.0e9));

  simMfdInitAll(sim_get_main_viewport());

  sim_init_plugins();

  if (!scripting_run_file("script/postinit.py")) {
    log_fatal("script/postinit.py missing");
  }

  sim_setup_menus(&gSIM_state);
}
Esempio n. 16
0
int main(void)
{
    log_init();
    log_set_level(LOG_DEBUG, NULL);
    log_set_file("cursor_check.log");

    cursor_check();

    log_fini();
    return EXIT_SUCCESS;
}
Esempio n. 17
0
/**
 * The logging uses log_level to determine if an incoming message is to be included in the log.
 * A high log_level setting will include more messages.
 */
void ert_log_init_log( int log_level , const char * log_file_name, bool verbose){
  logh = log_open( NULL , DEFAULT_LOG_LEVEL );
  
  log_set_level(logh, log_level);
  if (log_file_name)
    log_reopen( logh , log_file_name);

  if (verbose)
    printf("Activity will be logged to ..............: %s \n",log_get_filename( logh ));
  log_add_message(logh , 1 , NULL , "ert configuration loaded" , false);
}
Esempio n. 18
0
int log_set_level_by_str(const char *s) {
	uint16_t i;
	if(!s)
		return -1;
	for(i = 0; i < sizeof(level_map) / sizeof(struct level); i++) {
		if(!strcasecmp(level_map[i].name, s)) {
			log_set_level(level_map[i].level);
			return i;
		}
	}
	return -1;
}
Esempio n. 19
0
int main(int argc, char *argv[]) {
	blind_t my_bp;
	blind_t* bp = &my_bp;
	solver_t* sp = &(bp->solver);

	log_init(LOG_MSG);
    fits_use_error_system();

	if (argc == 2 && strcmp(argv[1], "-s") == 0) {
		log_set_level(LOG_NONE);
		fprintf(stderr, "premptive silence\n");
	}

	// Read input settings until "run" is encountered; repeat.
	for (;;) {
		tic();

		blind_init(bp);
		// must be in this order because init_parameters handily zeros out sp
		solver_set_default_values(sp);

		if (read_parameters(bp)) {
			solver_cleanup(sp);
			blind_cleanup(bp);
			break;
		}

		if (!blind_parameters_are_sane(bp, sp)) {
			exit(-1);
		}

		if (blind_is_run_obsolete(bp, sp)) {
            goto clean;
		}

        blind_log_run_parameters(bp);

		blind_run(bp);

        toc();

		if (bp->hit_total_timelimit)
			break;
		if (bp->hit_total_cpulimit)
			break;

    clean:
		solver_cleanup(sp);
		blind_cleanup(bp);
	}
	return 0;
}
Esempio n. 20
0
/*
 * Reads the configuration from a set of vars.
 */
static void load_config(struct http_user_vars_s *vars, struct config_s *config)
{
    http_get_bool_var(vars, VAR_ENABLED, &config->enabled);
    http_get_bool_var(vars, VAR_HIDE_TCP, &config->hide_tcp);
    http_get_bool_var(vars, VAR_HIDE_TCP_DATA, &config->hide_tcp_data);
    http_get_enum_var(vars, VAR_HIDE_TCP_SYN, flag_def, DEF_SIZE(flag_def),
        &config->hide_tcp_syn);
    http_get_enum_var(vars, VAR_HIDE_TCP_ACK, flag_def, DEF_SIZE(flag_def),
        &config->hide_tcp_ack);
    http_get_enum_var(vars, VAR_HIDE_TCP_PSH, flag_def, DEF_SIZE(flag_def),
        &config->hide_tcp_psh);
    http_get_enum_var(vars, VAR_HIDE_TCP_FIN, flag_def, DEF_SIZE(flag_def),
        &config->hide_tcp_fin);
    http_get_enum_var(vars, VAR_HIDE_TCP_RST, flag_def, DEF_SIZE(flag_def),
        &config->hide_tcp_rst);
    http_get_enum_var(vars, VAR_SPLIT_MODE, split_def, DEF_SIZE(split_def),
        &config->split);
    config_enum_t log_level;
    if (http_get_enum_var(vars, VAR_LOG_LEVEL, log_level_def,
        DEF_SIZE(log_level_def), &log_level))
    {
        log_set_level(log_level);
    }
    http_get_bool_var(vars, VAR_HIDE_UDP, &config->hide_udp);
    http_get_enum_var(vars, VAR_GHOST_MODE, ghost_def, DEF_SIZE(ghost_def),
        &config->ghost);
    http_get_bool_var(vars, VAR_GHOST_CHECK, &config->ghost_check);
    http_get_bool_var(vars, VAR_GHOST_SET_TTL, &config->ghost_set_ttl);
    http_get_int_var(vars, VAR_GHOST_TTL, 0, UINT8_MAX,
        sizeof(config->ghost_ttl), &config->ghost_ttl);
    http_get_enum_var(vars, VAR_FRAG_MODE, frag_def, DEF_SIZE(frag_def),
        &config->fragment);
    http_get_int_var(vars, VAR_TCP_PORT, 0, UINT16_MAX,
        sizeof(config->tcp_port), (uint8_t *)&config->tcp_port);
    const char *tcp_proto_name;
    if (http_get_string_var(vars, VAR_TCP_PROTO, &tcp_proto_name))
    {
        config->tcp_proto = protocol_get(tcp_proto_name);
    }
    http_get_int_var(vars, VAR_UDP_PORT, 0, UINT16_MAX,
        sizeof(config->udp_port), &config->udp_port);
    const char *udp_proto_name;
    if (http_get_string_var(vars, VAR_UDP_PROTO, &udp_proto_name))
    {
        config->udp_proto = protocol_get(udp_proto_name);
    }
    http_get_int_var(vars, VAR_MTU, 0, UINT16_MAX, sizeof(config->mtu),
        (uint8_t *)&config->mtu);
    http_get_bool_var(vars, VAR_LAUNCH_UI, &config->launch_ui);
}
Esempio n. 21
0
static
void
sighnd_handler(int sig)
{
  log_warning("Got signal [%d] %s\n", sig, strsignal(sig));

  switch( sig )
  {
  case SIGUSR1:
    log_set_level(LOG_DEBUG);
    log_emit(LOG_WARNING, "log verbosity -> DEBUG\n");
    break;

  case SIGUSR2:
    log_set_level(LOG_WARNING);
    log_emit(LOG_WARNING, "log verbosity -> WARNING\n");
    break;

  default:
    sighnd_terminate();
    break;
  }
}
Esempio n. 22
0
int main(void)
{
    log_init();
    log_set_level(LOG_DEBUG, NULL);
    log_set_file("ip_addr_check.log");

    ip_addr_check();
    ip_addr_ctor_from_str_check();
    ip_addr_routable_check();
    broadcast_check();
    scm_conv_check();

    log_fini();
    return EXIT_SUCCESS;
}
Esempio n. 23
0
File: dns.c Progetto: SpComb/nwprog
int main (int argc, char **argv)
{
    int err = 0;

    log_set_level(LOG_DEBUG);
    
    // skip argv0
    argv++;

    for (struct pack_name_test *test = pack_name_tests; test->pack || test->unpack; test++) {
        err |= test_pack_name(test);
    }

    return err;
}
Esempio n. 24
0
static gint lua_log_newindex(lua_State* lua) {
  if (lua_type(lua, 2) != LUA_TSTRING) return 0;

  if (strcmp(lua_tostring(lua, 2), "level") == 0) {
    if (lua_type(lua, 3) != LUA_TSTRING) return 0;

    const gchar* value = lua_tostring(lua, 3);
    for (enum log_level level = LOG_LEVEL_DEBUG;
         level <= LOG_LEVEL_FATAL;
         level++) {
      if (strcmp(log_levels[level], value) == 0) log_set_level(level);
    }
  }
  return 0;
}
Esempio n. 25
0
static int _start_logging(void)
{
    char fn_error[FILENAME_MAX];
    char fn_access[FILENAME_MAX];
    char pbuf[1024];

    ice_config_t *config = config_get_config_unlocked();

    if(strcmp(config->error_log, "-")) {
        snprintf(fn_error, FILENAME_MAX, "%s%s%s", config->log_dir, PATH_SEPARATOR, config->error_log);
        errorlog = log_open(fn_error);
    } else {
        errorlog = log_open_file(stderr);
    }
    if(strcmp(config->access_log, "-")) {
        snprintf(fn_access, FILENAME_MAX, "%s%s%s", config->log_dir, PATH_SEPARATOR, config->access_log);
        accesslog = log_open(fn_access);
    } else {
        accesslog = log_open_file(stderr);
    }
    
    log_set_level(errorlog, config->loglevel);
    log_set_level(accesslog, 4);

    if (errorlog < 0) {
        _fatal_error("FATAL: could not open error logging");
    }
    if (accesslog < 0) {
        memset(pbuf, '\000', sizeof(pbuf));
        snprintf(pbuf, sizeof(pbuf)-1, "FATAL: could not open access logging");
        _fatal_error(pbuf);
    }
    if (errorlog >= 0 && accesslog >= 0) return 1;
    
    return 0;
}
Esempio n. 26
0
void thread_initialize(void)
{
    thread_type *thread;

    /* set up logging */

#ifdef THREAD_DEBUG
    log_initialize();
    _logid = log_open("thread.log");
    log_set_level(_logid, THREAD_DEBUG);
#endif

#ifdef DEBUG_MUTEXES
    /* create all the internal mutexes, and initialize the mutex tree */

    _mutextree = avl_tree_new(_compare_mutexes, NULL);

    /* we have to create this one by hand, because there's no
    ** mutextree_mutex to lock yet!
    */
    _mutex_create(&_mutextree_mutex);

    _mutextree_mutex.mutex_id = _next_mutex_id++;
    avl_insert(_mutextree, (void *)&_mutextree_mutex);
#endif

    thread_mutex_create(&_threadtree_mutex);
    thread_mutex_create(&_library_mutex);

    /* initialize the thread tree and insert the main thread */

    _threadtree = avl_tree_new(_compare_threads, NULL);

    thread = (thread_type *)amalloc(sizeof(thread_type));

    thread->thread_id = _next_thread_id++;
    thread->line = 0;
    thread->file = strdup("main.c");
    thread->sys_thread = pthread_self();
    thread->create_time = time(NULL);
    thread->name = strdup("Main Thread");

    avl_insert(_threadtree, (void *)thread);

    _catch_signals();

    _initialized = 1;
}
Esempio n. 27
0
/** Initialize the logging drivers and options. */
static void kd_init_logging() {
    int i;
    int is_filtered;    
    char buf[256];
    char *ce, *channel, *last;
    const char *log_chan_enabled;
    const char *log_driver;
    const char log_driver_fmt[] = "log_%s.driver";
    const char log_filtered_fmt[] = "log_%s.filter";
    /* Order matters here.  This is the order of the LOG_* constants
       found in /usr/include/sys/syslog.h. */
    const char *log_levels[] = {"emergency", 
                                "alert",
                                "critical", 
                                "error",
                                "warning",
                                "notice",
                                "info",
                                "debug", 
                                NULL};
    
    /* Configure the basic log levels. */
    for (i = 0; log_levels[i] != NULL; i++) {        
        /* Read the log driver.  If none was provided, we use the null
           driver. */
        sprintf(buf, log_driver_fmt, log_levels[i]);
        log_driver = options_get_str(buf);

        /* Check if the level needs to be filtered.  If the value was
           not provided we default to no. */        
        sprintf(buf, log_filtered_fmt, log_levels[i]);
        is_filtered = options_get_bool(buf);

        log_set_level(i, log_driver, is_filtered);
    }

    /* Configure the enabled channels. */
    log_chan_enabled = options_get_str("log_channel.enabled");
    if (strcmp(log_chan_enabled, "") == 0) return;
    ce = strdup(log_chan_enabled);
    
    for (channel = apr_strtok(ce, " ", &last); 
         channel != NULL;
         channel = apr_strtok(NULL, " ", &last)) 
        log_enable_channel(channel);
    free(ce);
}
Esempio n. 28
0
int main(void)
{
    log_init();
    ext_init();
    mallocer_init();
    mutex_init();
    log_set_level(LOG_DEBUG, NULL);
    log_set_file("mallocer_check.log");

    malloc_check();
    realloc_check();

    mutex_fini();
    mallocer_fini();
    ext_fini();
    log_fini();

    return EXIT_SUCCESS;
}
Esempio n. 29
0
int default_main(int argc, char *argv[]){
        
    int result;

    TestDescriptor *p;

    log_set_level(LOG_LEVEL_INFO);

    /* execute all tests */
    result = 0;
    for (p=testDescriptor; (p->name!=NULL); p++) {
        //log_debug("executing test %s", p->name);
        if (p->func!=NULL) { 
            result = execute(argc, argv, p->name, p->func) || result;
            fflush(NULL);
        }
    }
    return result;
}
Esempio n. 30
0
void cga_init() {
    vmem_map(spc_current(), CGA_VR_PHYSICAL, (void*)CGA_VR_LOCATION, PG_WRITABLE);

    asm("cld; rep stosl;"
        :   /* no output */
        :   "D"(CGA_VR_LOCATION),
            "c"(CGA_VR_SIZE / 4),
            "a"(0x0F200F20)
        );

    /* hide the cursor */
    outb(0xA, 0x3D4);
    outb(0x20, 0x3D5);

    __cga_x = __cga_y = 0;

    log_add_writer(cga_write, "screen-log");
    log_set_level("screen-log", Info);
}