コード例 #1
0
PARCLogReporter *
parcLogReporterTextStdout_Create(void)
{
    PARCFileOutputStream *fileOutput = parcFileOutputStream_Create(dup(STDOUT_FILENO));
    PARCOutputStream *out = parcFileOutputStream_AsOutputStream(fileOutput);
    parcFileOutputStream_Release(&fileOutput);

    PARCLogReporter *result = parcLogReporter_Create(&parcLogReporterTextStdout_Acquire,
                                                     parcLogReporterTextStdout_Release,
                                                     parcLogReporterTextStdout_Report,
                                                     parcOutputStream_Acquire(out));
    parcOutputStream_Release(&out);
    return result;
}
コード例 #2
0
static PARCLog *
_parc_logger_create(const char *name)
{
    PARCFileOutputStream *fileOutput = parcFileOutputStream_Create(dup(STDOUT_FILENO));
    PARCOutputStream *output = parcFileOutputStream_AsOutputStream(fileOutput);
    parcFileOutputStream_Release(&fileOutput);

    PARCLogReporter *reporter = parcLogReporterFile_Create(output);
    parcOutputStream_Release(&output);

    PARCLog *log = parcLog_Create("localhost", "athenaTransport", name, reporter);
    parcLogReporter_Release(&reporter);

    parcLog_SetLevel(log, PARCLogLevel_Info);
    return log;
}
コード例 #3
0
ファイル: athena.c プロジェクト: chris-wood/ghost
static PARCLog *
_athena_logger_create(void)
{
    PARCFileOutputStream *fileOutput = parcFileOutputStream_Create(dup(STDOUT_FILENO));
    PARCOutputStream *output = parcFileOutputStream_AsOutputStream(fileOutput);
    parcFileOutputStream_Release(&fileOutput);

    PARCLogReporter *reporter = parcLogReporterFile_Create(output);
    parcOutputStream_Release(&output);

    PARCLog *log = parcLog_Create("localhost", "athena", NULL, reporter);
    parcLogReporter_Release(&reporter);

    parcLog_SetLevel(log, PARCLogLevel_Info);
    return log;
}
コード例 #4
0
ファイル: test_parc_Log.c プロジェクト: isolis/Libparc
LONGBOW_TEST_CASE(CreateDestroy, parcLog_Create)
{
    PARCFileOutputStream *fileOutput = parcFileOutputStream_Create(dup(STDOUT_FILENO));
    PARCOutputStream *output = parcFileOutputStream_AsOutputStream(fileOutput);
    parcFileOutputStream_Release(&fileOutput);

    PARCLogReporter *reporter = parcLogReporterFile_Create(output);
    parcOutputStream_Release(&output);

    PARCLog *log = parcLog_Create("localhost", "test_parc_Log", NULL, reporter);
    parcLogReporter_Release(&reporter);

    assertTrue(parcLogLevel_Equals(parcLog_GetLevel(log), PARCLogLevel_Off), "Expected initial log level to be OFF");

    parcLog_Release(&log);
}
コード例 #5
0
ファイル: metis_daemon.c プロジェクト: isolis/Metis
static MetisLogger *
_createLogfile(const char *logfile)
{
    int logfd = open(logfile, O_WRONLY | O_APPEND | O_CREAT, S_IWUSR | S_IRUSR);
    if (logfd < 0) {
        fprintf(stderr, "Error opening %s for writing: (%d) %s\n", logfile, errno, strerror(errno));
        exit(EXIT_FAILURE);
    }

    chmod(logfile, S_IRWXU);

    PARCFileOutputStream *fos = parcFileOutputStream_Create(logfd);
    PARCOutputStream *pos = parcFileOutputStream_AsOutputStream(fos);
    PARCLogReporter *reporter = parcLogReporterFile_Create(pos);

    MetisLogger *logger = metisLogger_Create(reporter, parcClock_Wallclock());

    parcOutputStream_Release(&pos);
    parcLogReporter_Release(&reporter);

    return logger;
}