Esempio n. 1
0
int InitializeLogs(const char *program_name)
{
    struct utsname uts;
    char          *tmp;
    int            rc;

    /* get node name */
    if (uname(&uts) == -1)
        strcpy(machine_name, "???");
    else
        rh_strncpy(machine_name, uts.nodename, RBH_PATH_MAX);

    /* if the name is the full machine name (node.subnet.domain.ext),
     * only kief the brief name */
    if ((tmp = strchr(machine_name, '.')) != NULL)
        *tmp = '\0';

    if (program_name == NULL)
        strcpy(prog_name, "???");
    else
        rh_strncpy(prog_name, program_name, RBH_PATH_MAX);

    /* open log files */
    rc = init_log_descr(log_config.log_file, &log);
    if (rc)
        return rc;

    rc = init_log_descr(log_config.report_file, &report);
    if (rc)
        return rc;

    if (!EMPTY_STRING(log_config.alert_file)) {
        rc = init_log_descr(log_config.alert_file, &alert);
        if (rc)
            return rc;
    }
#ifdef HAVE_CHANGELOGS
    if (!EMPTY_STRING(log_config.changelogs_file)) {
        rc = init_log_descr(log_config.changelogs_file, &chglogs);
        if (rc)
            return rc;
    }
#endif

    /* Update log level for external components we get logs from (LLAPI...) */
    rbh_adjust_log_level_external();

    last_time_test = time(NULL);
    log_initialized = true;

    return 0;

}   /* InitializeLogs */
Esempio n. 2
0
int InitializeLogs( char *program_name, const log_config_t * config )
{
    struct utsname uts;
    char          *tmp;
    int            rc;

    /* store module configuration */
    log_config = *config;

    /* get node name */

    if ( uname( &uts ) == -1 )
        strcpy( machine_name, "???" );
    else
        strncpy( machine_name, uts.nodename, RBH_PATH_MAX );

    /* if the name is the full machine name (node.subnet.domain.ext),
     * only kief the brief name */
    if ( ( tmp = strchr( machine_name, '.' ) ) != NULL )
        *tmp = '\0';

    if ( program_name == NULL )
        strcpy( prog_name, "???" );
    else
        strncpy( prog_name, program_name, RBH_PATH_MAX );

    /* open log files */
    rc = init_log_descr( log_config.log_file, &log );
    if (rc) return rc;

    rc = init_log_descr( log_config.report_file, &report );
    if (rc) return rc;

    if ( !EMPTY_STRING( log_config.alert_file ) )
    {
        rc = init_log_descr( log_config.alert_file, &alert );
        if (rc) return rc;
    }

    last_time_test = time( NULL );


    log_initialized = TRUE;

    return 0;

}   /* InitializeLogs */