Matrix Science Mascot Parser toolkit
 
Loading...
Searching...
No Matches
ms_log_impl.hpp
1/*
2##############################################################################
3# file: ms_log_impl.hpp #
4# 'msparser' toolkit #
5# Included from ms_log.hpp - but conditionally for when building the library #
6# #
7##############################################################################
8# COPYRIGHT NOTICE #
9# Copyright 1998-2018 Matrix Science Limited All Rights Reserved. #
10# #
11##############################################################################
12# $Archive:: /Mowse/ms_mascotresfile/include/ms_errors.hpp $ #
13# $Author: dcreasy@matrixscience.com $ #
14# $Date: 2020-02-17 11:03:19 +0000 $ #
15# $Revision: 16a3f4baa19a07d69f3cdf5833b81caa60bbc674 | MSPARSER_REL_3_0_0-2024-09-24-0-g93ebaeb4f4 $ #
16# $NoKeywords:: $ #
17##############################################################################
18*/
19
20#ifndef MS_LOG_IMPL_HPP
21#define MS_LOG_IMPL_HPP
22
23
24#ifndef SWIG
25#if defined(_INTERNAL_USE_AND_HAVE_BOOST_FORMAT) || defined(DOXYGEN_SHOULD_SKIP_THIS)
26
27#include "boost/format.hpp"
28
29namespace matrix_science {
30
31
32
33// It's OK to have templated functions in this file.
34// If the code for this, non template, function is added here you will
35// get multiply defined link warnings
36/*
37void ms_log::logMessage(ms_log::msg_num_t msgNum, const char * srcFile, const int lineNum)
38{
39 ms_log::msg_sev severity;
40 std::string unformattedMsg = _lookUpMsg(msgNum, severity);
41 _setError(static_cast<int>(msgNum), unformattedMsg.c_str(), severity, "", -1, lineNum, srcFile);
42} */
43
52template <typename T1>
53void ms_log::logMessage(ms_log::msg_num_t msgNum, const char * srcFile, const int lineNum, T1 arg1) {
54 if (willMessageBeLogged(msgNum)) {
55 ms_log::msg_sev severity;
56 std::string unformattedMsg = _lookUpMsg(msgNum, severity);
57 boost::format fmter(unformattedMsg);
58 if (fmter.expected_args() == 1) {
59 fmter % arg1;
60 _setError(static_cast<int>(msgNum), fmter.str().c_str(), severity, "", -1, lineNum, srcFile);
61 } else {
62 _setError(static_cast<int>(msgNum), unformattedMsg.c_str(), severity, "", -1, lineNum, srcFile);
63 }
64 }
65}
66
76template <typename T1, typename T2>
77void ms_log::logMessage(ms_log::msg_num_t msgNum, const char * srcFile, const int lineNum, T1 arg1, T2 arg2) {
78 if (willMessageBeLogged(msgNum)) {
79 ms_log::msg_sev severity;
80 std::string unformattedMsg = _lookUpMsg(msgNum, severity);
81 boost::format fmter(unformattedMsg);
82 if (fmter.expected_args() == 2) {
83 fmter % arg1 %arg2;
84 _setError(static_cast<int>(msgNum), fmter.str().c_str(), severity, "", -1, lineNum, srcFile);
85 } else {
86 _setError(static_cast<int>(msgNum), unformattedMsg.c_str(), severity, "", -1, lineNum, srcFile);
87 }
88 }
89}
90
101template <typename T1, typename T2, typename T3>
102void ms_log::logMessage(ms_log::msg_num_t msgNum, const char * srcFile, const int lineNum, T1 arg1, T2 arg2, T3 arg3) {
103 if (willMessageBeLogged(msgNum)) {
104 ms_log::msg_sev severity;
105 std::string unformattedMsg = _lookUpMsg(msgNum, severity);
106 boost::format fmter(unformattedMsg);
107 if (fmter.expected_args() == 3) {
108 fmter % arg1 %arg2 %arg3;
109 _setError(static_cast<int>(msgNum), fmter.str().c_str(), severity, "", -1, lineNum, srcFile);
110 } else {
111 _setError(static_cast<int>(msgNum), unformattedMsg.c_str(), severity, "", -1, lineNum, srcFile);
112 }
113 }
114}
115
116
128template <typename T1, typename T2, typename T3, typename T4>
129void ms_log::logMessage(ms_log::msg_num_t msgNum, const char * srcFile, const int lineNum, T1 arg1, T2 arg2, T3 arg3, T4 arg4) {
130 if (willMessageBeLogged(msgNum)) {
131 ms_log::msg_sev severity;
132 std::string unformattedMsg = _lookUpMsg(msgNum, severity);
133 boost::format fmter(unformattedMsg);
134 if (fmter.expected_args() == 4) {
135 fmter % arg1 %arg2 %arg3 %arg4;
136 _setError(static_cast<int>(msgNum), fmter.str().c_str(), severity, "", -1, lineNum, srcFile);
137 } else {
138 _setError(static_cast<int>(msgNum), unformattedMsg.c_str(), severity, "", -1, lineNum, srcFile);
139 }
140 }
141}
142
143
156template <typename T1, typename T2, typename T3, typename T4, typename T5>
157void ms_log::logMessage(ms_log::msg_num_t msgNum, const char * srcFile, const int lineNum, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) {
158 if (willMessageBeLogged(msgNum)) {
159 ms_log::msg_sev severity;
160 std::string unformattedMsg = _lookUpMsg(msgNum, severity);
161 boost::format fmter(unformattedMsg);
162 if (fmter.expected_args() == 5) {
163 fmter % arg1 %arg2 %arg3 %arg4 %arg5;
164 _setError(static_cast<int>(msgNum), fmter.str().c_str(), severity, "", -1, lineNum, srcFile);
165 } else {
166 _setError(static_cast<int>(msgNum), unformattedMsg.c_str(), severity, "", -1, lineNum, srcFile);
167 }
168 }
169}
170
184template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
185void ms_log::logMessage(ms_log::msg_num_t msgNum, const char * srcFile, const int lineNum, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6) {
186 if (willMessageBeLogged(msgNum)) {
187 ms_log::msg_sev severity;
188 std::string unformattedMsg = _lookUpMsg(msgNum, severity);
189 boost::format fmter(unformattedMsg);
190 if (fmter.expected_args() == 6) {
191 fmter % arg1 %arg2 %arg3 %arg4 %arg5 %arg6;
192 _setError(static_cast<int>(msgNum), fmter.str().c_str(), severity, "", -1, lineNum, srcFile);
193 } else {
194 _setError(static_cast<int>(msgNum), unformattedMsg.c_str(), severity, "", -1, lineNum, srcFile);
195 }
196 }
197}
198
213template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
214void ms_log::logMessage(ms_log::msg_num_t msgNum, const char * srcFile, const int lineNum, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7) {
215 if (willMessageBeLogged(msgNum)) {
216 ms_log::msg_sev severity;
217 std::string unformattedMsg = _lookUpMsg(msgNum, severity);
218 boost::format fmter(unformattedMsg);
219 if (fmter.expected_args() == 7) {
220 fmter % arg1 %arg2 %arg3 %arg4 %arg5 %arg6 %arg7;
221 _setError(static_cast<int>(msgNum), fmter.str().c_str(), severity, "", -1, lineNum, srcFile);
222 }
223 else {
224 _setError(static_cast<int>(msgNum), unformattedMsg.c_str(), severity, "", -1, lineNum, srcFile);
225 }
226 }
227}
228
244template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
245void ms_log::logMessage(ms_log::msg_num_t msgNum, const char * srcFile, const int lineNum, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8) {
246 if (willMessageBeLogged(msgNum)) {
247 ms_log::msg_sev severity;
248 std::string unformattedMsg = _lookUpMsg(msgNum, severity);
249 boost::format fmter(unformattedMsg);
250 if (fmter.expected_args() == 8) {
251 fmter % arg1 %arg2 %arg3 %arg4 %arg5 %arg6 %arg7 %arg8;
252 _setError(static_cast<int>(msgNum), fmter.str().c_str(), severity, "", -1, lineNum, srcFile);
253 }
254 else {
255 _setError(static_cast<int>(msgNum), unformattedMsg.c_str(), severity, "", -1, lineNum, srcFile);
256 }
257 }
258}
259
276template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9>
277void ms_log::logMessage(ms_log::msg_num_t msgNum, const char * srcFile, const int lineNum, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9) {
278 if (willMessageBeLogged(msgNum)) {
279 ms_log::msg_sev severity;
280 std::string unformattedMsg = _lookUpMsg(msgNum, severity);
281 boost::format fmter(unformattedMsg);
282 if (fmter.expected_args() == 9) {
283 fmter % arg1 %arg2 %arg3 %arg4 %arg5 %arg6 %arg7 %arg8 %arg9;
284 _setError(static_cast<int>(msgNum), fmter.str().c_str(), severity, "", -1, lineNum, srcFile);
285 }
286 else {
287 _setError(static_cast<int>(msgNum), unformattedMsg.c_str(), severity, "", -1, lineNum, srcFile);
288 }
289 }
290}
291
292#endif
293#endif
294
295} // namespace matrix_science
296
297#endif // MS_LOG_IMPL_HPP
298
299/*------------------------------- End of File -------------------------------*/
int msg_num_t
Typedef for log and error message numbers.
Definition: ms_log.hpp:127
bool willMessageBeLogged(const msg_num_t msgNum) const
Check to see if the message will be logged to a file or recorded anywhere.
Definition: ms_log.cpp:277
msg_sev
Message severity levels.
Definition: ms_log.hpp:47