| # Gaudi Framework, version v21r10p1 |

Home |  | Generated: 29 Jul 2010

# Message.cpp File Reference

`#include <string>`
`#include <iostream>`
`#include <iomanip>`
`#include <cstdlib>`
`#include <cstdio>`
`#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::ostream & | operator<< (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 | ( | x |  | ) | case x: level=#x; break

## Function Documentation

std::string @419::formattedTime | ( | std::string | fmt,
|  | bool | universal |
| ) |  |  | `[static]`

Definition at line 456 of file Message.cpp.

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

std::string @419::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 149 of file Message.cpp.

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

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

Insert the message into a stream.

Definition at line 175 of file Message.cpp.

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