3 /**************************************************************************
4 * This file is property of and copyright by the ALICE HLT Project *
5 * ALICE Experiment at CERN, All rights reserved. *
7 * Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
8 * for The ALICE HLT Project. *
10 * Permission to use, copy, modify and distribute this software and its *
11 * documentation strictly for non-commercial purposes is hereby granted *
12 * without fee, provided that the above copyright notice appears in all *
13 * copies and that both the copyright notice and this permission notice *
14 * appear in the supporting documentation. The authors make no claims *
15 * about the suitability of this software for any purpose. It is *
16 * provided "as is" without express or implied warranty. *
17 **************************************************************************/
19 /** @file AliHLTDynamicAliLog.cxx
20 @author Matthias Richter
22 @brief Implementation of dynamically loaded AliLog functionality
28 #include "AliHLTLogging.h"
29 #include "AliHLTDataTypes.h"
32 * Notification callback for AliRoot logging methods
34 void LogNotification(AliLog::EType_t level, const char* message)
36 // Notification callback for AliRoot logging methods
39 // in case of the initialized callback we never want to redirect
40 // HLT logging messages to AliLog (that would be a circular function call)
41 hltlog.SwitchAliLog(0);
42 hltlog.Logging(kHLTLogInfo, "NotificationHandler", "AliLog", AliHLTLogging::fgLogstr.str().c_str());
43 AliHLTLogging::fgLogstr.clear();
45 AliHLTLogging::fgLogstr.str(empty);
49 * This is the entry point for AliLog messages.
50 * The function pointer is fetched by the AliLogging class after libAliHLTUtil
51 * was loaded dynamically. By that we can keep libHLTbase free of AliRoot
54 extern "C" int AliDynamicMessage(AliHLTComponentLogSeverity severity,
55 const char* originClass, const char* originFunc,
56 const char* file, int line, const char* message)
58 // see header file for class documentation
61 case kHLTLogBenchmark:
62 AliLog::Message(AliLog::kInfo, message, "HLT", originClass, originFunc, file, line);
65 AliLog::Message(AliLog::kDebug, message, "HLT", originClass, originFunc, file, line);
68 AliLog::Message(AliLog::kInfo, message, "HLT", originClass, originFunc, file, line);
71 AliLog::Message(AliLog::kWarning, message, "HLT", originClass, originFunc, file, line);
74 AliLog::Message(AliLog::kError, message, "HLT", originClass, originFunc, file, line);
77 AliLog::Message(AliLog::kWarning, message, "HLT", originClass, originFunc, file, line);
86 * Init the AliLog callback.
87 * If libHLTbase is used within AliRoot, no message callback is initialized since
88 * all logging happens through AliRoot. If externally used by other frameworks (e.g.
89 * PubSub), all messages from components to AliLog must be trapped and redirected
90 * to the external callback.
92 extern "C" int InitAliDynamicMessageCallback()
94 // older versions of AliLog does not support the notification callback and
95 // stringstreams, but they support the logging macros in general
96 #ifndef NO_ALILOG_NOTIFICATION
97 AliLog* log=new AliLog;
98 log->SetLogNotification(LogNotification);
99 log->SetStreamOutput(&AliHLTLogging::fgLogstr);
101 #endif // NO_ALILOG_NOTIFICATION