Exemple #1
0
/* prepend time to log message and flush out to debug log file */
static void
debug_log__(aim_log_handler_t handler,
            aim_log_flag_t flag, const char* str)
{
    struct timeval timeval;
    struct tm *loctime;
    char lt[128];

    if(handler->debug_fp == NULL) {
        return;
    }

    gettimeofday(&timeval, NULL);
    loctime = localtime(&timeval.tv_sec);
    strftime(lt, sizeof(lt), "%FT%T", loctime);

    aim_sem_take(handler->debug_lock);

    fprintf(handler->debug_fp, "%s.%.06d %s %s", lt,
            (int)timeval.tv_usec, aim_log_flag_name(flag), str);
    fflush(handler->debug_fp);

    rotate_debug_log__(handler);

    aim_sem_give(handler->debug_lock);
}
Exemple #2
0
/**
 * Show log settings.
 */
void
aim_log_show(aim_log_t* lobj, aim_pvs_t* pvs)
{
    int i;
    int count;
    aim_map_si_t* map;

    aim_printf(pvs, "name: %s\n", lobj->name);
    aim_printf(pvs, "dest: %s\n", aim_pvs_desc_get(lobj->pvs));

    count = 0;
    aim_printf(pvs, "enabled options: ");
    /* @fixme */
    for(i = 0; i <= AIM_LOG_OPTION_TIMESTAMP; i++) {
        if(AIM_BIT_GET(lobj->options, i)) {
            aim_printf(pvs, "%s ", aim_log_option_name(i));
            count++;
        }
    }
    if(count == 0) {
        aim_printf(pvs, "none.");
    }
    aim_printf(pvs, "\n");


    count = 0;
    aim_printf(pvs, "disabled options: ");
    for(i = 0; i <= AIM_LOG_OPTION_TIMESTAMP; i++) {
        if(AIM_BIT_GET(lobj->options, i) == 0) {
            aim_printf(pvs, "%s ", aim_log_option_name(i));
            count++;
        }
    }
    if(count == 0) {
        aim_printf(pvs, "none. ");
    }
    aim_printf(pvs, "\n");

    aim_printf(pvs, "enabled: ");
    count = 0;
    /* @fixme */
    for(i = 0; i <= AIM_LOG_FLAG_FTRACE; i++) {
        if(AIM_BIT_GET(lobj->common_flags, i)) {
            aim_printf(pvs, "%s ", aim_log_flag_name(i));
            count++;
        }
    }
    for(map = lobj->custom_map; map && map->s; map++) {
        if(AIM_BIT_GET(lobj->custom_flags, map->i)) {
            aim_printf(pvs, "%s ", map->s);
            count++;
        }
    }
    if(count == 0) {
        aim_printf(pvs, "none.");
    }
    aim_printf(pvs, "\n");

    aim_printf(pvs, "disabled: ");
    count = 0;
    for(i = 0; i < AIM_LOG_FLAG_FTRACE; i++) {
        if(AIM_BIT_GET(lobj->common_flags, i) == 0) {
            aim_printf(pvs, "%s ", aim_log_flag_name(i));
            count++;
        }
    }
    for(map = lobj->custom_map; map && map->s; map++)  {
        if(AIM_BIT_GET(lobj->custom_flags, map->i) == 0) {
            aim_printf(pvs, "%s ", map->s);
            count++;
        }
    }
    if(count == 0) {
        aim_printf(pvs, "none");
    }
    aim_printf(pvs, "\n");
}