kim-api 2.3.0+AppleClang.AppleClang.GNU
An Application Programming Interface (API) for the Knowledgebase of Interatomic Models (KIM).
Loading...
Searching...
No Matches
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-2.3.0 package.
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
41namespace KIM
42{
43// Forward declarations
44class LogVerbosity;
45class LanguageName;
46class LogImplementation;
47
53class 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
125
131 std::string const & GetID() const;
132
140 void SetID(std::string const & id);
141
149 void PushVerbosity(LogVerbosity const logVerbosity);
150
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_
An Extensible Enumeration for the LanguageName's supported by the KIM API.
Provides the logging interface for the KIM API.
Definition: KIM_Log.hpp:54
std::string const & GetID() const
Get the identity of the Log object.
void PopVerbosity()
Pop a LogVerbosity from the Log object's verbosity stack.
static void PopDefaultPrintFunction()
Pop a log PrintFunction from the KIM API global default log PrintFunction stack.
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 int Create(Log **const log)
Create a new KIM API Log object.
static void Destroy(Log **const log)
Destroy a previously Log::Create'd object.
static void PushDefaultVerbosity(LogVerbosity const logVerbosity)
Push a new default LogVerbosity onto the KIM API global default verbosity stack.
void PushVerbosity(LogVerbosity const logVerbosity)
Push a new LogVerbosity onto the Log object's verbosity stack.
void LogEntry(LogVerbosity const logVerbosity, std::stringstream const &message, int const lineNumber, std::string const &fileName) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
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 PopDefaultVerbosity()
Pop a LogVerbosity from the KIM API global default verbosity stack.
An Extensible Enumeration for the LogVerbosity's supported by the KIM API.
void() Function(void)
Generic function type.