kim-api  2.3.1-git+v2.3.0-git-2-g378406f9.GNU.GNU.
An Application Programming Interface (API) for the Knowledgebase of Interatomic Models (KIM).
KIM_Log.hpp
Go to the documentation of this file.
1 //
2 // KIM-API: An API for interatomic models
3 // Copyright (c) 2013--2022, Regents of the University of Minnesota.
4 // All rights reserved.
5 //
6 // Contributors:
7 // Ryan S. Elliott
8 //
9 // SPDX-License-Identifier: LGPL-2.1-or-later
10 //
11 // This library is free software; you can redistribute it and/or
12 // modify it under the terms of the GNU Lesser General Public
13 // License as published by the Free Software Foundation; either
14 // version 2.1 of the License, or (at your option) any later version.
15 //
16 // This library is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 // Lesser General Public License for more details.
20 //
21 // You should have received a copy of the GNU Lesser General Public License
22 // along with this library; if not, write to the Free Software Foundation,
23 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 //
25 
26 //
27 // Release: This file is part of the kim-api.git repository.
28 //
29 
30 
31 #ifndef KIM_LOG_HPP_
32 #define KIM_LOG_HPP_
33 
34 #include <sstream>
35 #include <string>
36 
37 #ifndef KIM_FUNCTION_TYPES_HPP_
38 #include "KIM_FunctionTypes.hpp" // IWYU pragma: export
39 #endif
40 
41 namespace KIM
42 {
43 // Forward declarations
44 class LogVerbosity;
45 class LanguageName;
46 class LogImplementation;
47 
53 class Log
54 {
55  public:
65  static int Create(Log ** const log);
66 
78  static void Destroy(Log ** const log);
79 
91  static void PushDefaultVerbosity(LogVerbosity const logVerbosity);
92 
100  static void PopDefaultVerbosity();
101 
114  static void PushDefaultPrintFunction(LanguageName const languageName,
115  Function * const fptr);
116 
124  static void PopDefaultPrintFunction();
125 
131  std::string const & GetID() const;
132 
140  void SetID(std::string const & id);
141 
149  void PushVerbosity(LogVerbosity const logVerbosity);
150 
156  void PopVerbosity();
157 
172  void LogEntry(LogVerbosity const logVerbosity,
173  std::string const & message,
174  int const lineNumber,
175  std::string const & fileName) const;
176 
178  void LogEntry(LogVerbosity const logVerbosity,
179  std::stringstream const & message,
180  int const lineNumber,
181  std::string const & fileName) const;
182 
183  private:
184  // do not allow copy constructor or operator=
185  Log(Log const &);
186  void operator=(Log const &);
187 
188  Log();
189  ~Log();
190 
191  LogImplementation * pimpl;
192 }; // class Log
193 } // namespace KIM
194 
195 #endif // KIM_LOG_HPP_
static void PushDefaultVerbosity(LogVerbosity const logVerbosity)
Push a new default LogVerbosity onto the KIM API global default verbosity stack.
std::string const & GetID() const
Get the identity of the Log object.
void PopVerbosity()
Pop a LogVerbosity from the Log object&#39;s verbosity stack.
static void PopDefaultVerbosity()
Pop a LogVerbosity from the KIM API global default verbosity stack.
Provides the logging interface for the KIM API.
Definition: KIM_Log.hpp:53
void LogEntry(LogVerbosity const logVerbosity, std::string const &message, int const lineNumber, std::string const &fileName) const
Write a log entry into the log file.
static void PopDefaultPrintFunction()
Pop a log PrintFunction from the KIM API global default log PrintFunction stack.
void() Function(void)
Generic function type.
void SetID(std::string const &id)
Set the identity of the Log object.
static void PushDefaultPrintFunction(LanguageName const languageName, Function *const fptr)
Push a new default log PrintFunction onto the KIM API global default log PrintFunction stack...
static void Destroy(Log **const log)
Destroy a previously Log::Create&#39;d object.
An Extensible Enumeration for the LogVerbosity&#39;s supported by the KIM API.
An Extensible Enumeration for the LanguageName&#39;s supported by the KIM API.
void PushVerbosity(LogVerbosity const logVerbosity)
Push a new LogVerbosity onto the Log object&#39;s verbosity stack.
static int Create(Log **const log)
Create a new KIM API Log object.