-
Notifications
You must be signed in to change notification settings - Fork 128
/
Copy pathadiosLog.h
99 lines (87 loc) · 3.2 KB
/
adiosLog.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
89
90
91
92
93
94
95
96
97
98
99
/*
* Distributed under the OSI-approved Apache License, Version 2.0. See
* accompanying file Copyright.txt for details.
*
* adiosLog.h
*
* Created on: Nov 15, 2021
* Author: Jason Wang jason.ruonan.wang@gmail.com
*/
#ifndef ADIOS2_HELPER_ADIOSLOG_H_
#define ADIOS2_HELPER_ADIOSLOG_H_
#include <string>
namespace adios2
{
namespace helper
{
enum LogMode : char
{
EXCEPTION = 'x',
ERROR = 'e',
WARNING = 'w',
INFO = 'i'
};
std::string MakeMessage(const std::string &component, const std::string &source,
const std::string &activity, const std::string &message,
const int commRank, const LogMode mode);
/**
* Print outputs, warnings, errors, and exceptions
* @param component: Engine, Transport, Operator, etc.
* @param source: class name of component
* @param activity: function name where this is called
* @param message: text message
* @param mode: INFO, WARNING or ERROR
*/
void Log(const std::string &component, const std::string &source,
const std::string &activity, const std::string &message,
const LogMode mode);
/**
* Print outputs, warnings, errors, and exceptions
* @param component: Engine, Transport, Operator, etc.
* @param source: class name of component
* @param activity: function name where this is called
* @param message: text message
* @param priority: only print if(priority<=verbosity)
* @param verbosity: engine parameter for engine wide verbosity level
* @param mode: INFO, WARNING or ERROR
*/
void Log(const std::string &component, const std::string &source,
const std::string &activity, const std::string &message,
const int priority, const int verbosity, const LogMode mode);
/**
* Print outputs, warnings, errors, and exceptions
* @param component: Engine, Transport, Operator, etc.
* @param source: class name of component
* @param activity: function name where this is called
* @param message: text message
* @param logRank: only print if(logRank==commRank)
* @param commRank: current MPI rank
* @param priority: only print if(priority<=verbosity)
* @param verbosity: engine parameter for engine wide verbosity level
* @param mode: INFO, WARNING or ERROR
*/
void Log(const std::string &component, const std::string &source,
const std::string &activity, const std::string &message,
const int logRank, const int commRank, const int priority,
const int verbosity, const LogMode mode);
template <class T>
void Throw(const std::string &component, const std::string &source,
const std::string &activity, const std::string &message,
const int commRank = -1)
{
auto m = MakeMessage(component, source, activity, message, commRank,
LogMode::EXCEPTION);
throw(T(m));
}
template <class T>
void ThrowNested(const std::string &component, const std::string &source,
const std::string &activity, const std::string &message,
const int commRank = -1)
{
auto m = MakeMessage(component, source, activity, message, commRank,
LogMode::EXCEPTION);
throw_with_nested(T(m));
}
} // end namespace helper
} // end namespace adios2
#endif /* ADIOS2_HELPER_ADIOSLOG_H_ */