Changeset 8088 for trunk


Ignore:
Timestamp:
10/17/06 13:57:59 (18 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r8087 r8088  
    1818
    1919                                                 -*-*- END OF LINE -*-*-
     20 2006/10/17 Thomas Bretz
     21
     22   * mdata/MDataPhrase.cc:
     23     - updated comments
     24     - only add the missing functions to TDataPrimitives when not
     25       yet done. Everything lse would leak memory
     26
     27   * mhbase/MH3.[h,cc], mhvstime/MHVsTime.[h,cc]:
     28     - exchanged the MDataChain by MDataPhrase
     29     - therefore changed the datamember from MDataChain* to MData*
     30       (this change is not necessarily backward compatible)
     31     - increased class version number by one
     32
     33   * mraw/MRawRunHeader.h:
     34     - added getter for fObservationMode
     35
     36   * callisto.cc, ganymed.cc, merpp.cc, readdaq.cc, readraw.cc,
     37     showplot.cc, sinope.cc, star.cc, rootlogon.C
     38     - enabled error redirection
     39
     40   * mbase/MLog.[h,cc]:
     41     - added code to allow redirection of root error handler to
     42       out own error handler
     43
     44
     45
    2046 2006/10/17 Markus Meyer
    2147
    22    * mtools
    23      - added a new class called MRolke, which is a modification of
    24        TRolke from root_v5.12.00b. There is now a new function, called
    25        LogFactorial() which enables to calculate confidence intervals
    26        even for a large number of events (larger than 170).
     48   * mtools/MRolke.[h,cc]:
     49     - added: a modification of TRolke from root_v5.12.00b. There is
     50       now a new function, called LogFactorial() which enables to
     51       calculate confidence intervals even for a large number of
     52       events (larger than 170).
    2753
    2854
     
    78104   * mbase/MMath.cc:
    79105     - small update to SolvePol3 which is more accurate in the number
    80        or different solutions
     106       of different solutions
    81107
    82108   * mdata/DataLinkDef.h, mdata/Makefile:
  • trunk/MagicSoft/Mars/NEWS

    r8071 r8088  
    55   - general: The programs now return 0xfe if the requested resource file
    66     doesn't exist.
     7
     8   - general: Errors comming from root itself are now not output to
     9     stderr anymore but to our default (colored) log-stream.
    710
    811
  • trunk/MagicSoft/Mars/callisto.cc

    r8071 r8088  
    145145        return 0xff;
    146146
     147    MLog::RedirectErrorHandler(MLog::kColor);
     148
    147149    //
    148150    // Evaluate arguments
  • trunk/MagicSoft/Mars/ganymed.cc

    r8071 r8088  
    9494        return 0xff;
    9595
     96    MLog::RedirectErrorHandler(MLog::kColor);
     97
    9698    //
    9799    // Evaluate arguments
  • trunk/MagicSoft/Mars/macros/rootlogon.C

    r7413 r8088  
    122122        return;
    123123
     124    MLog::RedirectErrorHandler(MLog::kColor);
     125
    124126    gInterpreter->AddIncludePath(dir+"macros");
    125127    gInterpreter->AddIncludePath(dir+"manalysis");
  • trunk/MagicSoft/Mars/mbase/MLog.cc

    r7941 r8088  
    108108#include <TGTextView.h>
    109109
     110#include <TEnv.h>       // gEnv (ErrorHandler)
     111#include <TError.h>     // TError (SetErrorHandler)
     112
    110113#include "MArgs.h"
    111114#include "MTime.h"
     
    113116
    114117#include "MLogHtml.h"
     118#include "MLogManip.h"  // inf,warn,err (MLog::ErrorHandler)
    115119
    116120ClassImp(MLog);
     
    153157void MLog::Init()
    154158{
    155 
    156159    //
    157160    // Creat drawing semaphore
     
    745748    return rc;
    746749}
     750
     751// --------------------------------------------------------------------------
     752//
     753// Check whether errors at this level should be ignored.
     754//
     755bool MLog::ErrorHandlerIgnore(Int_t level)
     756{
     757    // The default error handler function. It prints the message on stderr and
     758    // if abort is set it aborts the application.
     759   if (gErrorIgnoreLevel == kUnset) {
     760      R__LOCKGUARD2(gErrorMutex);
     761
     762      gErrorIgnoreLevel = 0;
     763      if (gEnv) {
     764         TString level = gEnv->GetValue("Root.ErrorIgnoreLevel", "Info");
     765         if (!level.CompareTo("Info",TString::kIgnoreCase))
     766            gErrorIgnoreLevel = kInfo;
     767         else if (!level.CompareTo("Warning",TString::kIgnoreCase))
     768            gErrorIgnoreLevel = kWarning;
     769         else if (!level.CompareTo("Error",TString::kIgnoreCase))
     770            gErrorIgnoreLevel = kError;
     771         else if (!level.CompareTo("Break",TString::kIgnoreCase))
     772            gErrorIgnoreLevel = kBreak;
     773         else if (!level.CompareTo("SysError",TString::kIgnoreCase))
     774            gErrorIgnoreLevel = kSysError;
     775         else if (!level.CompareTo("Fatal",TString::kIgnoreCase))
     776            gErrorIgnoreLevel = kFatal;
     777      }
     778   }
     779
     780   return level < gErrorIgnoreLevel;
     781}
     782
     783// --------------------------------------------------------------------------
     784//
     785// Output the root error message to the log-stream.
     786//
     787void MLog::ErrorHandlerPrint(Int_t level, const char *location, const char *msg)
     788{
     789    R__LOCKGUARD2(gErrorMutex);
     790
     791    if (level >= kError)
     792        gLog << "ROOT:Error";
     793    else
     794        if (level >= kSysError)
     795            gLog << "SysError";
     796        else
     797            if (level >= kBreak)
     798                gLog << "\n *** Break ***";
     799            else
     800                if (level >= kFatal)
     801                    gLog << "Fatal";
     802                else
     803                    if (level >= kWarning)
     804                        gLog << "ROOT:Warning";
     805                    else
     806                        if (level >= kInfo)
     807                            gLog << "ROOT:Info";
     808
     809    if (level >= kBreak && level < kSysError)
     810        gLog << " " << msg << std::endl;
     811    else
     812        if (!location || strlen(location) == 0)
     813            gLog << ": " << msg << std::endl;
     814        else
     815            gLog << " in <" << location << ">: " << msg << std::endl;
     816}
     817
     818// --------------------------------------------------------------------------
     819//
     820// A new error handler using gLog instead of stderr as output.
     821// It is mainly a copy of root's DefaultErrorHandler
     822// (see TError.h and TError.cxx)
     823//
     824void MLog::ErrorHandlerCol(Int_t level, Bool_t abort, const char *location, const char *msg)
     825{
     826    if (ErrorHandlerIgnore(level))
     827        return;
     828
     829    gLog << std::flush;
     830
     831    if (level >= kInfo)
     832       gLog << inf;
     833    if (level >= kWarning)
     834        gLog << warn;
     835    if (level >= kError)
     836        gLog << err;
     837
     838    ErrorHandlerPrint(level, location, msg);
     839
     840    gLog << std::flush;
     841    if (!abort)
     842        return;
     843
     844    gLog << err << "aborting" << std::endl;
     845    if (gSystem) {
     846        gSystem->StackTrace();
     847        gSystem->Abort();
     848    } else
     849        ::abort();
     850}
     851
     852// --------------------------------------------------------------------------
     853//
     854// A new error handler using gLog instead of stderr as output.
     855// It is mainly a copy of root's DefaultErrorHandler
     856// (see TError.h and TError.cxx)
     857//
     858void MLog::ErrorHandlerAll(Int_t level, Bool_t abort, const char *location, const char *msg)
     859{
     860    if (ErrorHandlerIgnore(level))
     861        return;
     862
     863    gLog << std::flush << all;
     864
     865    ErrorHandlerPrint(level, location, msg);
     866
     867    gLog << std::flush;
     868    if (!abort)
     869        return;
     870
     871    gLog << err << "aborting" << std::endl;
     872    if (gSystem) {
     873        gSystem->StackTrace();
     874        gSystem->Abort();
     875    } else
     876        ::abort();
     877}
     878
     879// --------------------------------------------------------------------------
     880//
     881// Redirect the root ErrorHandler (see TError.h) output to gLog.
     882//
     883// The diffrent types are:
     884//  kColor:      Use gLog colors
     885//  kBlackWhite: Use all-qualifier (as in gLog << all << endl;)
     886//  kDefault:    Set back to root's default error handler
     887//               (redirect output to stderr)
     888//
     889void MLog::RedirectErrorHandler(ELogType typ)
     890{
     891    switch (typ)
     892    {
     893    case kColor:
     894        SetErrorHandler(MLog::ErrorHandlerCol);
     895        break;
     896    case kBlackWhite:
     897        SetErrorHandler(MLog::ErrorHandlerAll);
     898        break;
     899    case kDefault:
     900        SetErrorHandler(DefaultErrorHandler);
     901    }
     902}
  • trunk/MagicSoft/Mars/mbase/MLog.h

    r7949 r8088  
    3535    enum ELogBits {
    3636        kHasChanged = BIT(14)  // if gui has changed
     37    };
     38
     39    enum ELogType {
     40        kDefault,
     41        kColor,
     42        kBlackWhite
    3743    };
    3844
     
    95101    void AddGuiLine(const TString& line);
    96102
     103    // User defined error handling (see TError.h)
     104    static bool ErrorHandlerIgnore(Int_t level);
     105    static void ErrorHandlerPrint(Int_t level, const char *location, const char *msg);
     106    static void ErrorHandlerCol(Int_t level, Bool_t abort, const char *location, const char *msg);
     107    static void ErrorHandlerAll(Int_t level, Bool_t abort, const char *location, const char *msg);
     108
    97109public:
     110
    98111    MLog(int i=eStdout);
    99112    MLog(ofstream &out);
     
    110123
    111124    static TString Intro();
     125    static void RedirectErrorHandler(ELogType typ=kColor);
    112126
    113127    bool LockUpdate(const char *msg);
  • trunk/MagicSoft/Mars/merpp.cc

    r8011 r8088  
    150150        return 0xff;
    151151
     152    MLog::RedirectErrorHandler(MLog::kColor);
     153
    152154    //
    153155    // Evaluate arguments
  • trunk/MagicSoft/Mars/readdaq.cc

    r8011 r8088  
    6262        return 0xff;
    6363
     64    MLog::RedirectErrorHandler(MLog::kColor);
     65
    6466    //
    6567    // Evaluate arguments
  • trunk/MagicSoft/Mars/readraw.cc

    r8011 r8088  
    7272    if (!MARS::CheckRootVer())
    7373        return 0xff;
     74
     75    MLog::RedirectErrorHandler(MLog::kColor);
    7476
    7577    // Evaluate arguments
  • trunk/MagicSoft/Mars/showplot.cc

    r8011 r8088  
    9393        return 0xff;
    9494
     95    MLog::RedirectErrorHandler(MLog::kColor);
     96
    9597    //
    9698    // Evaluate arguments
  • trunk/MagicSoft/Mars/sinope.cc

    r8011 r8088  
    269269        return 0xff;
    270270
     271    MLog::RedirectErrorHandler(MLog::kColor);
     272
    271273    //
    272274    // Evaluate arguments
  • trunk/MagicSoft/Mars/star.cc

    r8071 r8088  
    9494        return 0xff;
    9595
     96    MLog::RedirectErrorHandler(MLog::kColor);
     97
    9698    //
    9799    // Evaluate arguments
Note: See TracChangeset for help on using the changeset viewer.