ATLAS Offline Software
Loading...
Searching...
No Matches
MessagePrinter.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7
8
9//
10// includes
11//
12
14
15#include <iomanip>
16#include <iostream>
17
18//
19// method implementations
20//
21
22namespace asg
23{
24 MessagePrinter ::
25 MessagePrinter (unsigned val_sourceWidth)
26 : m_sourceWidth (val_sourceWidth)
27 {
28 }
29
30
31
32 void MessagePrinter ::
33 print (MSG::Level reqlvl, const std::string& name,
34 const std::string& text)
35 {
36 // A stream to construct the printed message in. In order not to have to
37 // manipulate std::cout directly.
38 std::ostringstream output;
39 output << std::setiosflags( std::ios::left );
40
41 // add the tool name, shortening it as necessary
42 if( name.size() > m_sourceWidth )
43 {
44 output << name.substr( 0, m_sourceWidth - 3 );
45 output << "...";
46 } else
47 {
48 output << std::setw( m_sourceWidth ) << name;
49 }
50
51 // add the level of the message
52 output << std::setw( 7 ) << MSG::name( reqlvl );
53
54 // Print the message payload:
55 std::cout << output.str() << " " << text << std::endl;
56 }
57}
const std::string & name(Level lvl)
Convenience function for translating message levels to strings.
Definition MsgLevel.cxx:19
output
Definition merge.py:16