示例#1
0
VXIlogResult OSBlog::ErrorLog(const VXIchar*   moduleName,
                              VXIunsigned      errorID,
                              const VXIchar*   format,
                              va_list          args)
{
    const VXIchar *finalModuleName =
        (moduleName && moduleName[0] ? moduleName : L"UNKNOWN");

    // Output the log message
    LogEntry entry;
    entry.AddEntrySep();
    entry += channelNum;
    entry.AddEntrySep();
    entry += finalModuleName;
    entry.AddEntrySep();
    entry += errorID;
    entry.AddEntrySep();
    VXIlogResult rc = entry.AppendKeyValueVa(format, args);
    entry.Terminate();

    VXIlogResult rc2 = WriteEntry(entry);
    if (rc2 != VXIlog_RESULT_SUCCESS)
        rc = rc2;

    // Want to warn the caller that NULL moduleName really isn't OK, but
    // logged it anyway
    if ((! moduleName) || (! moduleName[0]))
        rc = VXIlog_RESULT_INVALID_ARGUMENT;

    return rc;
}
示例#2
0
VXIlogResult OSBlog::DiagnosticLog(VXIunsigned     tagID,
                                   const VXIchar*  subtag,
                                   const VXIchar*  format,
                                   va_list         args)
{
    VXIunsigned bindex, bpos;
    if (!Convert2Index(tagID, &bindex, &bpos))
        return VXIlog_RESULT_INVALID_ARGUMENT;

    if (! format)
        return VXIlog_RESULT_SUCCESS;

    // if this tag is not turned on, just return
    if (!testbit(TagIDs[bindex],bpos))
        return VXIlog_RESULT_SUCCESS;

    if (subtag == NULL)
        subtag = L"";

    // Output the log message
    LogEntry entry;
    entry.AddEntrySep();
    entry += channelNum;
    entry.AddEntrySep();
    entry += tagID;
    entry.AddEntrySep();
    entry += subtag;
    entry.AddEntrySep();
    VXIlogResult rc;
    if (args == 0)
        rc = entry.Append(format, wcslen(format));
    else
        rc = entry.AppendVa(format, args);
    entry.Terminate();

    VXIlogResult rc2 = WriteEntry(entry);
    if (rc2 != VXIlog_RESULT_SUCCESS)
        rc = rc2;

    return rc;
}
示例#3
0
VXIlogResult OSBlog::EventLog(VXIunsigned      eventID,
                              const VXIchar*   format,
                              va_list          args)
{
    // Output the log message
    LogEntry entry;
    entry.AddEntrySep();
    entry += channelNum;
    entry.AddEntrySep();
    entry += L"EVENT";
    entry.AddEntrySep();
    entry += eventID;
    entry.AddEntrySep();
    VXIlogResult rc = entry.AppendKeyValueVa(format, args);
    entry.Terminate();

    // Don't write events to stdout
    VXIlogResult rc2 = WriteEntry(entry, false);
    if (rc2 != VXIlog_RESULT_SUCCESS)
        rc = rc2;

    return rc;
}