mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-15 09:31:45 +00:00
Zero MQ implimentation and example (Tutorial3)
git-svn-id: https://subversion.gsi.de/fairroot/fairbase/trunk@20162 0381ead4-6506-0410-b988-94b70fbc4730
This commit is contained in:
71
fairmq/FairMQLogger.cxx
Normal file
71
fairmq/FairMQLogger.cxx
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* FairMQLogger.cxx
|
||||
*
|
||||
* Created on: Dec 4, 2012
|
||||
* Author: dklein
|
||||
*/
|
||||
|
||||
#include "FairMQLogger.h"
|
||||
#include <iostream>
|
||||
#include <ctime>
|
||||
#include <iomanip>
|
||||
|
||||
|
||||
FairMQLogger* FairMQLogger::instance = NULL;
|
||||
|
||||
FairMQLogger* FairMQLogger::GetInstance()
|
||||
{
|
||||
if (instance == NULL) {
|
||||
instance = new FairMQLogger();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
FairMQLogger* FairMQLogger::InitInstance(TString bindAddress)
|
||||
{
|
||||
instance = new FairMQLogger(bindAddress);
|
||||
return instance;
|
||||
}
|
||||
|
||||
FairMQLogger::FairMQLogger() :
|
||||
fBindAddress("")
|
||||
{
|
||||
}
|
||||
|
||||
FairMQLogger::FairMQLogger(TString bindAddress) :
|
||||
fBindAddress(bindAddress)
|
||||
{
|
||||
}
|
||||
|
||||
FairMQLogger::~FairMQLogger()
|
||||
{
|
||||
}
|
||||
|
||||
void FairMQLogger::Log(Int_t type, TString logmsg)
|
||||
{
|
||||
timestamp_t tm = get_timestamp();
|
||||
timestamp_t ms = tm / 1000.0L;
|
||||
timestamp_t s = ms / 1000.0L;
|
||||
std::time_t t = s;
|
||||
std::size_t fractional_seconds = ms % 1000;
|
||||
Text_t mbstr[100];
|
||||
std::strftime(mbstr, 100, "%H:%M:%S:", std::localtime(&t));
|
||||
|
||||
TString type_str;
|
||||
switch (type) {
|
||||
case DEBUG:
|
||||
type_str = "\033[01;34mDEBUG\033[0m";
|
||||
break;
|
||||
case INFO:
|
||||
type_str = "\033[01;32mINFO\033[0m";
|
||||
break;
|
||||
case ERROR:
|
||||
type_str = "\033[01;31mERROR\033[0m";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
std::cout << "[\033[01;36m" << mbstr << fractional_seconds << "\033[0m]" << "[" << type_str << "]" << " " << logmsg << std::endl;
|
||||
}
|
||||
|
Reference in New Issue
Block a user