kim-api  2.2.1+v2.2.1.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 // CDDL HEADER START
3 //
4 // The contents of this file are subject to the terms of the Common Development
5 // and Distribution License Version 1.0 (the "License").
6 //
7 // You can obtain a copy of the license at
8 // http://www.opensource.org/licenses/CDDL-1.0. See the License for the
9 // specific language governing permissions and limitations under the License.
10 //
11 // When distributing Covered Code, include this CDDL HEADER in each file and
12 // include the License file in a prominent location with the name LICENSE.CDDL.
13 // If applicable, add the following below this CDDL HEADER, with the fields
14 // enclosed by brackets "[]" replaced with your own identifying information:
15 //
16 // Portions Copyright (c) [yyyy] [name of copyright owner]. All rights reserved.
17 //
18 // CDDL HEADER END
19 //
20 
21 //
22 // Copyright (c) 2016--2020, Regents of the University of Minnesota.
23 // All rights reserved.
24 //
25 // Contributors:
26 // Ryan S. Elliott
27 //
28 
29 //
30 // Release: This file is part of the kim-api-2.2.1 package.
31 //
32 
33 
34 #ifndef KIM_LOG_HPP_
35 #define KIM_LOG_HPP_
36 
37 #include <sstream>
38 #include <string>
39 
40 #ifndef KIM_FUNCTION_TYPES_HPP_
41 #include "KIM_FunctionTypes.hpp" // IWYU pragma: export
42 #endif
43 
44 namespace KIM
45 {
46 // Forward declarations
47 class LogVerbosity;
48 class LanguageName;
49 class LogImplementation;
50 
56 class Log
57 {
58  public:
68  static int Create(Log ** const log);
69 
81  static void Destroy(Log ** const log);
82 
94  static void PushDefaultVerbosity(LogVerbosity const logVerbosity);
95 
103  static void PopDefaultVerbosity();
104 
117  static void PushDefaultPrintFunction(LanguageName const languageName,
118  Function * const fptr);
119 
127  static void PopDefaultPrintFunction();
128 
134  std::string const & GetID() const;
135 
143  void SetID(std::string const & id);
144 
152  void PushVerbosity(LogVerbosity const logVerbosity);
153 
159  void PopVerbosity();
160 
175  void LogEntry(LogVerbosity const logVerbosity,
176  std::string const & message,
177  int const lineNumber,
178  std::string const & fileName) const;
179 
181  void LogEntry(LogVerbosity const logVerbosity,
182  std::stringstream const & message,
183  int const lineNumber,
184  std::string const & fileName) const;
185 
186  private:
187  // do not allow copy constructor or operator=
188  Log(Log const &);
189  void operator=(Log const &);
190 
191  Log();
192  ~Log();
193 
194  LogImplementation * pimpl;
195 }; // class Log
196 } // namespace KIM
197 
198 #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:56
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.