Gaudi Framework, version v21r4

Home   Generated: 7 Sep 2009

Message.cpp File Reference

#include <string>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cctype>
#include "GaudiKernel/IMessageSvc.h"
#include "GaudiKernel/Message.h"
#include "GaudiKernel/Timing.h"
#include "GaudiKernel/time_r.h"

Include dependency graph for Message.cpp:

Go to the source code of this file.

Defines

#define SET(x)   case x: level=#x; break

Functions

std::string formattedTime (std::string fmt, bool universal=false)
std::ostreamoperator<< (std::ostream &stream, const Message &msg)
 Insert the message into a stream.
bool operator== (const Message &a, const Message &b)
 Insert the message into a stream.
std::string formattedTime (std::string fmt, bool universal)


Define Documentation

#define SET (  )     case x: level=#x; break


Function Documentation

std::string @401::formattedTime ( std::string  fmt,
bool  universal 
) [static]

Definition at line 455 of file Message.cpp.

00456   {
00457     // get current time in milliseconds
00458     longlong t = System::currentTime( System::milliSec );
00459     int msec = static_cast<int>(t % 1000);
00460     time_t sec = static_cast<time_t>(t / 1000);
00461 
00462     // convert to break-down time
00463     struct tm tms ;
00464     if (universal) {
00465       gmtime_r( &sec, &tms );
00466     } else {
00467       localtime_r( &sec, &tms );
00468     }
00469 
00470     // replace %f in the format string with miliseconds
00471     std::string::size_type n = fmt.find("%f") ;
00472     if ( n != std::string::npos ) {
00473       char subs[4] ;
00474       sprintf ( subs, "%03d", msec ) ;
00475       while ( n != std::string::npos ) {
00476         fmt.replace ( n, 2, subs ) ;
00477         n = fmt.find("%f") ;
00478       }
00479     }
00480 
00481     char buf[128] ;
00482     strftime(buf, 128, fmt.c_str(), &tms );
00483     return std::string( buf );
00484   }

std::string @401::formattedTime ( std::string  fmt,
bool  universal = false 
) [static]

std::ostream& operator<< ( std::ostream stream,
const Message msg 
)

Insert the message into a stream.

Definition at line 148 of file Message.cpp.

00149 {
00150   msg.makeFormattedMsg( msg.m_format );
00151   stream << msg.m_formatted_msg;
00152   return stream;
00153 }

bool operator== ( const Message a,
const Message b 
)

Insert the message into a stream.

Definition at line 174 of file Message.cpp.

00175 {
00176   return a.m_source == b.m_source &&
00177     a.m_type == b.m_type &&
00178     a.m_message == b.m_message;
00179 }


Generated at Mon Sep 7 18:12:30 2009 for Gaudi Framework, version v21r4 by Doxygen version 1.5.6 written by Dimitri van Heesch, © 1997-2004