MsgLogTErrorHandler.h File Reference

#include <stdio.h>
#include <string>
#include "TError.h"

Go to the source code of this file.

Functions

void MsgLogTErrorHandler (int level, Bool_t abort, const char *location, const char *msg)

Function Documentation

void MsgLogTErrorHandler ( int  level,
Bool_t  abort,
const char *  location,
const char *  msg 
)

Definition at line 21 of file MsgLogTErrorHandler.cxx.

References gSystem(), DDS::kError, Nav::kInfo, Nav::kWarning, logCritical(), logError(), logNotice(), and logWarn().

Referenced by main().

00023 {
00024   // This error handler function sends the messages to msgLog and
00025   // if abort is set it aborts the application.
00026   // 
00027   // Unlike "syslog", "msgLog" levels don't quite mesh w/ ROOT's levels
00028   //    ROOT       msgLog     msgLog function
00029   //     Info       Info      logInfo
00030   //                Notice    logNotice
00031   //     Warning    Warning   logWarn
00032   //     Error      Error     logError
00033   //     Break
00034   //     SysError   Critical  logCritical
00035   //     Fatal
00036 
00037 #define LOG_I
00038 
00039    if (level < gErrorIgnoreLevel) return;
00040 
00041    char msgPayload[1024];
00042    if (!location || strlen(location) == 0) 
00043      sprintf(msgPayload,"%s",msg);
00044    else
00045      sprintf(msgPayload,"<%s>: %s",location,msg);
00046 
00047    if      ( level >= kSysError ) logCritical(msgPayload);
00048    else if ( level >= kError    ) logError(msgPayload);
00049    else if ( level >= kWarning  ) logWarn(msgPayload);
00050    else if ( level >= kInfo     ) logNotice(msgPayload); // ?logInfo?
00051    
00052    if (abort) {
00053       logCritical("aborting because of \"%s\"",msgPayload);
00054       if (gSystem) {
00055          gSystem->StackTrace();
00056          gSystem->Abort();
00057       } else
00058          ::abort();
00059    }
00060 }


Generated on 2 Nov 2017 for loon by  doxygen 1.6.1