コード例 #1
0
ファイル: os_diag.c プロジェクト: xrl/opensplice_dds
static void
os_defaultDiag (
    const char   *cluster,
    os_diagLevel  level,
    const char   *description,
    va_list 	  args)
{
    os_time ostime;
    char extended_description[512];
    char procIdentity[64];
    char threadIdentity[64];
    char node[64];

    ostime = os_timeGet();

    os_vsnprintf (extended_description, sizeof(extended_description)-1, description, args);
    extended_description [sizeof(extended_description)-1] = '\0';

    os_gethostname (node, sizeof(node));
    os_threadFigureIdentity (threadIdentity, sizeof (threadIdentity)-1);
    threadIdentity [sizeof (threadIdentity)-1] = '\0';
    os_procFigureIdentity (procIdentity, sizeof (procIdentity)-1);
    procIdentity [sizeof (procIdentity)-1] = '\0';

    printf (
        "Diag - %s:%s:%s - T:%d.%9.9d L:%s C:%s D:%s\n",
        node,
        procIdentity,
        threadIdentity,
        ostime.tv_sec,
        ostime.tv_nsec,
        os_diagLevelText[level],
        cluster,
        extended_description);
}
コード例 #2
0
ファイル: os_report.c プロジェクト: S73417H/opensplice
static void
os_defaultReport(
    os_reportEventV1 event)
{
    os_time ostime;
    char node[64];
    char date_time[128];
    FILE *log;
    time_t tt;


    switch (event->reportType) {
    case OS_DEBUG:
    case OS_INFO:
    case OS_WARNING:
      /* Check info_file is NULL here to keep user loggging */
      /* plugin simple in integrity */
      if ( info_log == NULL )
      {
        info_log = os_open_info_file();
      }
      log = info_log;
      break;
    case OS_API_INFO:
    case OS_ERROR:
    case OS_CRITICAL:
    case OS_FATAL:
    case OS_REPAIRED:
    default:
      /* Check error_file is NULL here to keep user loggging */
      /* plugin simple in integrity */
      if ( error_log == NULL )
      {
        error_log = os_open_error_file();
      }
      log = error_log;
      break;
    }

    ostime = os_timeGet();
    tt = ostime.tv_sec;
    if (strftime(date_time, sizeof(date_time), "%a %b %d %H:%M:%S %Z %Y", localtime(&tt)) == 0) {
        date_time[0] = '\0';
    }

    os_gethostname(node, sizeof(node)-1);
    node[sizeof(node)-1] = '\0';

    os_mutexLock(&reportMutex);
#ifdef INTEGRITY
    os_logprintf( log,
#else
    fprintf(log,
#endif
            "========================================================================================\n"
            "Report      : %s\n"
            "Date        : %s\n"
            "Description : %s\n"
            "Node        : %s\n"
            "Process     : %s\n"
            "Thread      : %s\n"
            "Internals   : %s/%s/%s/%s/%s/%d/%d/%d.%09d\n",
            os_reportTypeText[event->reportType],
            date_time,
            event->description,
            node,
            event->processDesc,
            event->threadDesc,
            OSPL_VERSION_STR,
            OSPL_INNER_REV_STR,
            OSPL_OUTER_REV_STR,
            event->reportContext,
            event->fileName,
            event->lineNo,
            event->code,
            ostime.tv_sec,
            ostime.tv_nsec);
#ifndef INTEGRITY
    fflush (log);
#endif
    os_mutexUnlock(&reportMutex);
}