1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 ///////////////////////////////////////////////////////////////////////////////
20 // class for logging debug, info and error messages //
22 // The AliLog class is a singleton class. It allows to steer the output //
23 // level and output streams for different types of messages via static //
26 // It also handles the messages produces by the preprocessor macros defined //
27 // in the header file: AliDebug, AliInfo, AliWarning, AliError, AliFatal. //
29 // More details about the message logging can be found on the ALICE Offline //
32 ///////////////////////////////////////////////////////////////////////////////
34 #include <Riostream.h>
45 AliLog* AliLog::fgInstance = NULL;
47 Bool_t AliLog::fgDebugEnabled = kTRUE;
50 //_____________________________________________________________________________
53 fGlobalLogLevel(kInfo),
57 // default constructor: set default values
59 for (Int_t iType = kFatal; iType < kMaxType; iType++) {
60 fOutputTypes[iType] = 0;
61 fFileNames[iType] = "";
62 fOutputFiles[iType] = NULL;
63 fOutputStreams[iType] = NULL;
65 fPrintType[iType] = kTRUE;
66 fPrintModule[iType] = kFALSE;
67 fPrintScope[iType] = kTRUE;
68 fPrintLocation[iType] = (iType == kDebug);
71 SetHandleRootMessages(kTRUE);
73 // replace the previous instance by this one
74 if (fgInstance) delete fgInstance;
77 // read the .rootrc settings
81 //_____________________________________________________________________________
84 // destructor: clean up and reset instance pointer
86 for (Int_t i = 0; i < fModuleDebugLevels.GetEntriesFast(); i++) {
87 if (fModuleDebugLevels[i]) fModuleDebugLevels[i]->Delete();
89 fClassDebugLevels.Delete();
90 for (Int_t i = 0; i < fClassDebugLevels.GetEntriesFast(); i++) {
91 if (fClassDebugLevels[i]) fClassDebugLevels[i]->Delete();
93 fClassDebugLevels.Delete();
95 for (Int_t iType = kFatal; iType < kMaxType; iType++) {
104 //_____________________________________________________________________________
105 AliLog::AliLog(const AliLog& log) :
110 Fatal("AliLog", "copy constructor not implemented");
113 //_____________________________________________________________________________
114 AliLog& AliLog::operator = (const AliLog& /*log*/)
116 // assignment operator
118 Fatal("operator =", "assignment operator not implemented");
123 //_____________________________________________________________________________
124 void AliLog::ReadEnvSettings()
126 // load settings from the root configuration file (.rootrc)
127 // and from environment variables
129 static const char* typeNames[kMaxType] =
130 {"kFatal", "kError", "kWarning", "kInfo", "kDebug"};
132 // debug en- or disabling
133 if (gSystem->Getenv("LOG_NO_DEBUG")) {
134 fgDebugEnabled = kFALSE;
135 } else if (gEnv->Defined("AliRoot.AliLog.EnableDebug")) {
136 fgDebugEnabled = gEnv->GetValue("AliRoot.AliLog.EnableDebug",
138 AliInfo(Form("debug %sabled", ((fgDebugEnabled) ? "en" : "dis")));
142 if (gEnv->Defined("AliRoot.AliLog.GlobalLogLevel")) {
143 const char* type = gEnv->GetValue("AliRoot.AliLog.GlobalLogLevel", "");
144 for (Int_t iType = kFatal; iType < kMaxType; iType++) {
145 if (strcmp(type, typeNames[iType]) == 0) fGlobalLogLevel = iType;
147 AliDebug(3, Form("global log level set to %d", fGlobalLogLevel));
150 // global debug level
151 if (gEnv->Defined("AliRoot.AliLog.GlobalDebugLevel")) {
152 Int_t level = gEnv->GetValue("AliRoot.AliLog.GlobalDebugLevel",
153 Int_t(fGlobalLogLevel - kDebugOffset));
154 if (level < -kDebugOffset) level = kDebugOffset;
155 fGlobalLogLevel = kDebugOffset + level;
156 AliDebug(3, Form("global debug level set to %d",
157 fGlobalLogLevel - kDebugOffset));
160 // module debug level
161 if (gEnv->Defined("AliRoot.AliLog.ModuleDebugLevel")) {
162 TString levels = gEnv->GetValue("AliRoot.AliLog.ModuleDebugLevel", "");
163 char* p = const_cast<char*>(levels.Data());
164 while (const char* module = strtok(p, " ")) {
166 char* pos = index(module, ':');
169 Int_t level = atoi(pos);
170 SetModuleDebugLevel(module, level);
171 AliDebug(3, Form("debug level for module %s set to %d", module, level));
176 if (gEnv->Defined("AliRoot.AliLog.ClassDebugLevel")) {
177 TString levels = gEnv->GetValue("AliRoot.AliLog.ClassDebugLevel", "");
178 char* p = const_cast<char*>(levels.Data());
179 while (const char* className = strtok(p, " ")) {
181 char* pos = index(className, ':');
184 Int_t level = atoi(pos);
185 SetClassDebugLevel(className, level);
186 AliDebug(3, Form("debug level for class %s set to %d",
191 // general output stream
192 if (gEnv->Defined("AliRoot.AliLog.Output")) {
193 TString stream = gEnv->GetValue("AliRoot.AliLog.Output", "Standard");
194 if (stream.CompareTo("standard", TString::kIgnoreCase) == 0) {
196 AliDebug(3, "output stream set to standard output for all types");
197 } else if (stream.CompareTo("error", TString::kIgnoreCase) == 0) {
199 AliDebug(3, "output stream set to error output for all types");
200 } else if (!stream.IsNull()) {
201 SetFileOutput(stream);
202 AliDebug(3, Form("output stream set to file %s for all types",
207 // individual output streams
208 for (Int_t iType = kFatal; iType < kMaxType; iType++) {
209 TString name("AliRoot.AliLog.Output.");
210 name += &typeNames[iType][1];
211 if (gEnv->Defined(name)) {
212 TString stream = gEnv->GetValue(name, "Standard");
213 if (stream.CompareTo("standard", TString::kIgnoreCase) == 0) {
214 SetStandardOutput(EType(iType));
215 AliDebug(3, Form("output stream set to standard output for type %s",
217 } else if (stream.CompareTo("error", TString::kIgnoreCase) == 0) {
218 SetErrorOutput(EType(iType));
219 AliDebug(3, Form("output stream set to error output for type %s",
221 } else if (!stream.IsNull()) {
222 SetFileOutput(EType(iType), stream);
223 AliDebug(3, Form("output stream set to file %s for type %s",
224 stream.Data(), typeNames[iType]));
229 // handling of root error messages
230 if (gEnv->Defined("AliRoot.AliLog.HandleRootMessages")) {
231 Bool_t on = gEnv->GetValue("AliRoot.AliLog.HandleRootMessages", kTRUE);
232 SetHandleRootMessages(on);
233 AliDebug(3, Form("handling of root messages %sabled",
234 ((on) ? "en" : "dis")));
238 static const char* settingNames[4] =
239 {"Type", "Module", "Scope", "Location"};
241 {fPrintType, fPrintModule, fPrintScope, fPrintLocation};
242 for (Int_t iSetting = 0; iSetting < 4; iSetting++) {
243 TString name("AliRoot.AliLog.Print");
244 name += settingNames[iSetting];
245 if (gEnv->Defined(name)) {
246 Bool_t on = gEnv->GetValue(name, settings[iSetting][0]);
247 for (Int_t iType = kFatal; iType < kMaxType; iType++) {
248 settings[iSetting][iType] = on;
250 AliDebug(3, Form("printing of %s %sabled for all types",
251 settingNames[iSetting], ((on) ? "en" : "dis")));
254 for (Int_t iType = kFatal; iType < kMaxType; iType++) {
255 TString nameType = name + "." + &typeNames[iType][1];
256 if (gEnv->Defined(nameType)) {
257 Bool_t on = gEnv->GetValue(nameType, settings[iSetting][iType]);
258 settings[iSetting][iType] = on;
259 AliDebug(3, Form("printing of %s %sabled for type %s",
260 settingNames[iSetting], ((on) ? "en" : "dis"),
268 //_____________________________________________________________________________
269 void AliLog::RootErrorHandler(Int_t level, Bool_t abort,
270 const char* location, const char* message)
272 // new error handler for messages from root
275 case ::kFatal : level = kFatal; break;
277 DefaultErrorHandler(level, abort, location, message);
280 DefaultErrorHandler(level, abort, location, message);
282 case ::kError : level = kError; break;
283 case ::kWarning : level = kWarning; break;
284 case ::kInfo : level = kInfo; break;
285 default : level = kDebug; break;
287 AliLog::Message(level, message, "ROOT", NULL, location, NULL, 0);
291 //_____________________________________________________________________________
292 void AliLog::EnableDebug(Bool_t enabled)
294 // enable or disable debug output
296 fgDebugEnabled = enabled;
299 //_____________________________________________________________________________
300 void AliLog::SetGlobalLogLevel(EType type)
302 // set the global debug level
304 if (!fgInstance) new AliLog;
305 fgInstance->fGlobalLogLevel = type;
308 //_____________________________________________________________________________
309 Int_t AliLog::GetGlobalLogLevel()
311 // get the global debug level
313 if (!fgInstance) new AliLog;
314 return fgInstance->fGlobalLogLevel;
317 //_____________________________________________________________________________
318 void AliLog::SetGlobalDebugLevel(Int_t level)
320 // set the global debug level
322 if (!fgInstance) new AliLog;
323 if (level < -kDebugOffset) level = -kDebugOffset;
324 fgInstance->fGlobalLogLevel = kDebugOffset + level;
327 //_____________________________________________________________________________
328 Int_t AliLog::GetGlobalDebugLevel()
330 // get the global debug level
332 if (!fgInstance) new AliLog;
333 return fgInstance->fGlobalLogLevel - kDebugOffset;
336 //_____________________________________________________________________________
337 void AliLog::SetModuleDebugLevel(const char* module, Int_t level)
339 // set the debug level for the given module
342 if (!fgInstance) new AliLog;
343 TObject* obj = fgInstance->fModuleDebugLevels.FindObject(module);
345 obj = new TNamed(module, module);
346 fgInstance->fModuleDebugLevels.Add(obj);
348 level += kDebugOffset;
349 if (level < kFatal) level = kFatal;
350 obj->SetUniqueID(level);
353 //_____________________________________________________________________________
354 void AliLog::ClearModuleDebugLevel(const char* module)
356 // remove the setting of the debug level for the given module
359 if (!fgInstance) new AliLog;
360 TObject* obj = fgInstance->fModuleDebugLevels.FindObject(module);
361 if (obj) delete fgInstance->fModuleDebugLevels.Remove(obj);
364 //_____________________________________________________________________________
365 void AliLog::SetClassDebugLevel(const char* className, Int_t level)
367 // set the debug level for the given class
369 if (!className) return;
370 if (!fgInstance) new AliLog;
371 TObject* obj = fgInstance->fClassDebugLevels.FindObject(className);
373 obj = new TNamed(className, className);
374 fgInstance->fClassDebugLevels.Add(obj);
376 level += kDebugOffset;
377 if (level < kFatal) level = kFatal;
378 obj->SetUniqueID(level);
381 //_____________________________________________________________________________
382 void AliLog::ClearClassDebugLevel(const char* className)
384 // remove the setting of the debug level for the given class
386 if (!className) return;
387 if (!fgInstance) new AliLog;
388 TObject* obj = fgInstance->fClassDebugLevels.FindObject(className);
389 if (obj) delete fgInstance->fClassDebugLevels.Remove(obj);
393 //_____________________________________________________________________________
394 void AliLog::SetStandardOutput()
396 // write all log messages to the standard output (stdout)
398 if (!fgInstance) new AliLog;
399 for (Int_t iType = kFatal; iType < kMaxType; iType++) {
400 fgInstance->CloseFile(iType);
401 fgInstance->fOutputTypes[iType] = 0;
405 //_____________________________________________________________________________
406 void AliLog::SetStandardOutput(EType type)
408 // write log messages of the given type to the standard output (stdout)
410 if ((type < kFatal) || (type >= kMaxType)) return;
411 if (!fgInstance) new AliLog;
412 fgInstance->CloseFile(type);
413 fgInstance->fOutputTypes[type] = 0;
416 //_____________________________________________________________________________
417 void AliLog::SetErrorOutput()
419 // write all log messages to the error output (stderr)
421 if (!fgInstance) new AliLog;
422 for (Int_t iType = kFatal; iType < kMaxType; iType++) {
423 fgInstance->CloseFile(iType);
424 fgInstance->fOutputTypes[iType] = 1;
428 //_____________________________________________________________________________
429 void AliLog::SetErrorOutput(EType type)
431 // write log messages of the given type to the error output (stderr)
433 if ((type < kFatal) || (type >= kMaxType)) return;
434 if (!fgInstance) new AliLog;
435 fgInstance->CloseFile(type);
436 fgInstance->fOutputTypes[type] = 1;
439 //_____________________________________________________________________________
440 void AliLog::SetFileOutput(const char* fileName)
442 // write all log messages to the given file
444 if (!fgInstance) new AliLog;
445 for (Int_t iType = kFatal; iType < kMaxType; iType++) {
446 if ((fgInstance->fOutputTypes[iType] == 2) &&
447 (fgInstance->fFileNames[iType].CompareTo(fileName) != 0)) {
448 fgInstance->CloseFile(iType);
450 fgInstance->fOutputTypes[iType] = 2;
451 fgInstance->fFileNames[iType] = fileName;
452 fgInstance->fOutputFiles[iType] = NULL;
453 fgInstance->fOutputStreams[iType] = NULL;
457 //_____________________________________________________________________________
458 void AliLog::SetFileOutput(EType type, const char* fileName)
460 // write log messages of the given type to the given file
462 if ((type < kFatal) || (type >= kMaxType)) return;
463 if (!fgInstance) new AliLog;
464 if ((fgInstance->fOutputTypes[type] == 2) &&
465 (fgInstance->fFileNames[type].CompareTo(fileName) != 0)) {
466 fgInstance->CloseFile(type);
468 fgInstance->fOutputTypes[type] = 2;
469 fgInstance->fFileNames[type] = fileName;
470 fgInstance->fOutputFiles[type] = NULL;
471 fgInstance->fOutputStreams[type] = NULL;
474 //_____________________________________________________________________________
475 void AliLog::CloseFile(Int_t type)
477 // close the file for the given type if needed
479 if ((fOutputTypes[type] == 2) && fOutputFiles[type]) {
480 Bool_t closeFile = kTRUE;
481 for (Int_t iType = kFatal; iType < kMaxType; iType++) {
482 if ((iType != type) && (fOutputFiles[iType] == fOutputFiles[type])) {
487 fclose(fOutputFiles[type]);
488 fOutputStreams[type]->close();
489 delete fOutputStreams[type];
492 fOutputFiles[type] = NULL;
493 fOutputStreams[type] = NULL;
494 fFileNames[type] = "";
495 fOutputTypes[type] = 0;
498 //_____________________________________________________________________________
499 FILE* AliLog::GetOutputStream(Int_t type)
501 // get the output stream for the given type of messages
503 if (type > kDebug) type = kDebug;
504 if (fOutputTypes[type] == 0) return stdout;
505 else if (fOutputTypes[type] == 1) return stderr;
506 else if (fOutputTypes[type] == 2) {
507 if (!fOutputFiles[type]) {
509 ofstream* stream = NULL;
510 if (!fFileNames[type].IsNull()) {
511 for (Int_t iType = kFatal; iType < kMaxType; iType++) {
512 if ((iType != type) &&
513 (fFileNames[iType].CompareTo(fFileNames[type]) == 0) &&
514 fOutputFiles[iType]) {
515 file = fOutputFiles[iType];
516 stream = fOutputStreams[iType];
521 file = fopen(fFileNames[type], "a");
522 stream = new ofstream(fFileNames[type], ios::app);
525 fOutputFiles[type] = file;
526 fOutputStreams[type] = stream;
527 if (!file) CloseFile(type);
529 if (fOutputFiles[type]) return fOutputFiles[type];
535 //_____________________________________________________________________________
538 // flush the output streams
540 if (!fgInstance) new AliLog;
541 for (Int_t iType = kFatal; iType < kMaxType; iType++) {
542 if (fgInstance->fOutputFiles[iType]) {
543 fflush(fgInstance->fOutputFiles[iType]);
544 fgInstance->fOutputStreams[iType]->flush();
552 //_____________________________________________________________________________
553 void AliLog::SetHandleRootMessages(Bool_t on)
555 // enable or disable the handling of messages form root
558 SetErrorHandler(RootErrorHandler);
560 SetErrorHandler(DefaultErrorHandler);
565 //_____________________________________________________________________________
566 void AliLog::SetPrintType(Bool_t on)
568 // switch on or off the printing of the message type for all message types
570 if (!fgInstance) new AliLog;
571 for (Int_t iType = kFatal; iType < kMaxType; iType++) {
572 fgInstance->fPrintType[iType] = on;
576 //_____________________________________________________________________________
577 void AliLog::SetPrintType(EType type, Bool_t on)
579 // switch on or off the printing of the message type for the given message type
581 if ((type < kFatal) || (type >= kMaxType)) return;
582 if (!fgInstance) new AliLog;
583 fgInstance->fPrintType[type] = on;
586 //_____________________________________________________________________________
587 void AliLog::SetPrintModule(Bool_t on)
589 // switch on or off the printing of the module for all message types
591 if (!fgInstance) new AliLog;
592 for (Int_t iType = kFatal; iType < kMaxType; iType++) {
593 fgInstance->fPrintModule[iType] = on;
597 //_____________________________________________________________________________
598 void AliLog::SetPrintModule(EType type, Bool_t on)
600 // switch on or off the printing of the module for the given message type
602 if ((type < kFatal) || (type >= kMaxType)) return;
603 if (!fgInstance) new AliLog;
604 fgInstance->fPrintModule[type] = on;
607 //_____________________________________________________________________________
608 void AliLog::SetPrintScope(Bool_t on)
610 // switch on or off the printing of the scope/class name for all message types
612 if (!fgInstance) new AliLog;
613 for (Int_t iType = kFatal; iType < kMaxType; iType++) {
614 fgInstance->fPrintScope[iType] = on;
618 //_____________________________________________________________________________
619 void AliLog::SetPrintScope(EType type, Bool_t on)
621 // switch on or off the printing of the scope/class name
622 // for the given message type
624 if ((type < kFatal) || (type >= kMaxType)) return;
625 if (!fgInstance) new AliLog;
626 fgInstance->fPrintScope[type] = on;
629 //_____________________________________________________________________________
630 void AliLog::SetPrintLocation(Bool_t on)
632 // switch on or off the printing of the file name and line number
633 // for all message types
635 if (!fgInstance) new AliLog;
636 for (Int_t iType = kFatal; iType < kMaxType; iType++) {
637 fgInstance->fPrintLocation[iType] = on;
641 //_____________________________________________________________________________
642 void AliLog::SetPrintLocation(EType type, Bool_t on)
644 // switch on or off the printing of the file name and line number
645 // for the given message type
647 if ((type < kFatal) || (type >= kMaxType)) return;
648 if (!fgInstance) new AliLog;
649 fgInstance->fPrintLocation[type] = on;
653 //_____________________________________________________________________________
654 void AliLog::Write(const char* name, Int_t option)
656 // write the log object with the given name and option to the current file
658 if (!fgInstance) new AliLog;
659 fgInstance->TObject::Write(name, option);
663 //_____________________________________________________________________________
664 UInt_t AliLog::GetLogLevel(const char* module, const char* className) const
666 // get the logging level for the given module and class
668 if (!fgInstance) new AliLog;
669 TObject* obj = fgInstance->fClassDebugLevels.FindObject(className);
670 if (obj) return obj->GetUniqueID();
671 obj = fgInstance->fModuleDebugLevels.FindObject(module);
672 if (obj) return obj->GetUniqueID();
673 return fgInstance->fGlobalLogLevel;
676 //_____________________________________________________________________________
677 Int_t AliLog::GetDebugLevel(const char* module, const char* className)
679 // get the debug level for the given module and class
681 if (!fgInstance) new AliLog;
682 return fgInstance->GetLogLevel(module, className) - kDebugOffset;
685 //_____________________________________________________________________________
686 void AliLog::PrintMessage(UInt_t type, const char* message,
687 const char* module, const char* className,
688 const char* function, const char* file, Int_t line)
690 // print the given message
692 FILE* stream = GetOutputStream(type);
693 static const char* typeNames[kMaxType] =
694 {"Fatal", "Error", "Warning", "Info", "Debug"};
696 if (fPrintType[type]) {
697 fprintf(stream, "%s in ", typeNames[type]);
699 fprintf(stream, "<");
700 if (fPrintModule[type] && module) {
701 fprintf(stream, "%s/", module);
703 if (fPrintScope[type] && className) {
704 fprintf(stream, "%s::", className);
707 fprintf(stream, "%s>: %s", function, message);
709 fprintf(stream, "%s>", function);
711 if (fPrintLocation[type] && file) {
712 fprintf(stream, " (%s:%.0d)", file, line);
715 fprintf(stream, "\n");
717 fprintf(stream, ": ");
721 //_____________________________________________________________________________
722 void AliLog::Message(UInt_t level, const char* message,
723 const char* module, const char* className,
724 const char* function, const char* file, Int_t line)
726 // print a log message
728 if (!fgInstance) new AliLog;
730 // get the message type
732 if (type >= kMaxType) type = kMaxType - 1;
734 // print the message if the debug level allows
735 if (level <= fgInstance->GetLogLevel(module, className)) {
736 fgInstance->PrintMessage(type, message,
737 module, className, function, file, line);
740 // abort in case of a fatal message
741 if (type == kFatal) {
744 gSystem->StackTrace();
752 //_____________________________________________________________________________
753 void AliLog::Debug(UInt_t level, const char* message,
754 const char* module, const char* className,
755 const char* function, const char* file, Int_t line)
757 // print a debug message
759 if (level == 0) level = 1;
760 level += kDebugOffset;
761 Message(level, message, module, className, function, file, line);
765 //_____________________________________________________________________________
766 Int_t AliLog::RedirectStdoutTo(EType type, UInt_t level, const char* module,
767 const char* className, const char* function,
768 const char* file, Int_t line, Bool_t print)
770 // redirect the standard output to the stream of the given type
772 if (!fgInstance) new AliLog;
773 return fgInstance->RedirectTo(stdout, type, level, module, className,
774 function, file, line, print);
777 //_____________________________________________________________________________
778 Int_t AliLog::RedirectStderrTo(EType type, UInt_t level, const char* module,
779 const char* className, const char* function,
780 const char* file, Int_t line, Bool_t print)
782 // redirect the standard error output to the stream of the given type
784 if (!fgInstance) new AliLog;
785 return fgInstance->RedirectTo(stderr, type, level, module, className,
786 function, file, line, print);
789 //_____________________________________________________________________________
790 Int_t AliLog::RedirectTo(FILE* stream, EType type, UInt_t level,
791 const char* module, const char* className,
792 const char* function, const char* file, Int_t line,
795 // redirect the standard (error) output stream to the stream of the given type
797 // get the original file descriptor to be able to restore it later
798 Int_t original = dup(fileno(stream));
801 // flush the stream of the selected type
802 FILE* newStream = GetOutputStream(type);
806 if ((type == kDebug) && (level > 0)) level--;
807 if (type + level > GetLogLevel(module, className)) { // /dev/null
808 freopen("/dev/null", "a", stream);
809 } else if (fOutputTypes[type] == 0) { // stdout
810 if (stream != stdout) dup2(fileno(stdout), fileno(stream));
811 } else if (fOutputTypes[type] == 1) { // stderr
812 if (stream != stderr) dup2(fileno(stderr), fileno(stream));
813 } else if (fOutputTypes[type] == 2) { // file
814 freopen(fFileNames[type], "a", stream);
819 PrintMessage(type, NULL, module, className, function, file, line);
826 //_____________________________________________________________________________
827 void AliLog::RestoreStdout(Int_t original)
829 // restore the standard output
832 dup2(original, fileno(stdout));
835 //_____________________________________________________________________________
836 void AliLog::RestoreStderr(Int_t original)
838 // restore the standard error output
841 dup2(original, fileno(stderr));
845 //_____________________________________________________________________________
846 ostream& AliLog::Stream(EType type, UInt_t level,
847 const char* module, const char* className,
848 const char* function, const char* file, Int_t line)
850 // get the stream object for the given output type
852 if (!fgInstance) new AliLog;
853 return fgInstance->GetStream(type, level, module, className,
854 function, file, line);
857 //_____________________________________________________________________________
858 ostream& AliLog::GetStream(EType type, UInt_t level,
859 const char* module, const char* className,
860 const char* function, const char* file, Int_t line)
862 // get the stream object for the given output type
864 if ((type == kDebug) && (level > 0)) level--;
865 Bool_t noOutput = (type + level > GetLogLevel(module, className));
868 PrintMessage(type, NULL, module, className, function, file, line);
870 fflush(GetOutputStream(type));
872 static ofstream nullStream("/dev/null");
875 } else if (fOutputTypes[type] == 0) {
877 } else if (fOutputTypes[type] == 1) {
879 } else if (fOutputTypes[type] == 2) {
880 return *fOutputStreams[type];