-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTemplateLogogFormatterSuppressedGCC-impl.h
88 lines (72 loc) · 2.3 KB
/
TemplateLogogFormatterSuppressedGCC-impl.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/**
* \copyright
* Copyright (c) 2012-2017, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/
namespace BaseLib {
#ifdef USE_MPI
template <int T_SUPPPRESS_TOPIC_FLAG>
TemplateLogogFormatterSuppressedGCC<T_SUPPPRESS_TOPIC_FLAG>
::TemplateLogogFormatterSuppressedGCC(MPI_Comm mpi_comm)
{
int rank = 0;
MPI_Comm_rank(mpi_comm, &rank);
int size = 0;
MPI_Comm_size(mpi_comm, &size);
int digits = size/10 + 1;
_str_mpi_rank = "rank " + padLeft(std::to_string(rank), digits) + "| ";
}
#endif
template <int T_SUPPPRESS_TOPIC_FLAG>
LOGOG_STRING &
TemplateLogogFormatterSuppressedGCC<T_SUPPPRESS_TOPIC_FLAG>
::Format( const logog::Topic &topic, const logog::Target &target )
{
TOPIC_FLAGS flags;
flags = GetTopicFlags( topic );
m_sMessageBuffer.clear();
#ifdef USE_MPI
m_sMessageBuffer.append(_str_mpi_rank.c_str());
#endif
if ( flags & TOPIC_FILE_NAME_FLAG )
{
m_sMessageBuffer.append( topic.FileName() );
m_sMessageBuffer.append( ':' );
}
if ( flags & TOPIC_LINE_NUMBER_FLAG )
{
m_sIntBuffer.assign( topic.LineNumber() );
m_sMessageBuffer.append( m_sIntBuffer );
m_sMessageBuffer.append( LOGOG_CONST_STRING(": "));
}
RenderTimeOfDay();
if ( flags & TOPIC_LEVEL_FLAG )
{
m_sMessageBuffer.append( ErrorDescription( topic.Level()));
m_sMessageBuffer.append( LOGOG_CONST_STRING(": "));
}
if ( flags & TOPIC_GROUP_FLAG )
{
m_sMessageBuffer.append( LOGOG_CONST_STRING("{") );
m_sMessageBuffer.append( topic.Group() );
m_sMessageBuffer.append( LOGOG_CONST_STRING("} ") );
}
if ( flags & TOPIC_CATEGORY_FLAG )
{
m_sMessageBuffer.append( LOGOG_CONST_STRING("["));
m_sMessageBuffer.append( topic.Category() );
m_sMessageBuffer.append( LOGOG_CONST_STRING("] "));
}
if ( flags & TOPIC_MESSAGE_FLAG )
{
m_sMessageBuffer.append( topic.Message() );
m_sMessageBuffer.append( (LOGOG_CHAR)'\n' );
}
if ( target.GetNullTerminatesStrings() )
m_sMessageBuffer.append( (LOGOG_CHAR)NULL );
return m_sMessageBuffer;
}
} // namespace BaseLib