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 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
|
//
// KIM-API: An API for interatomic models
// Copyright (c) 2013--2022, Regents of the University of Minnesota.
// All rights reserved.
//
// Contributors:
// Ryan S. Elliott
//
// SPDX-License-Identifier: LGPL-2.1-or-later
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this library; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//
//
// Release: This file is part of the kim-api.git repository.
//
#ifndef KIM_LOG_HPP_
#define KIM_LOG_HPP_
#include <sstream>
#include <string>
#ifndef KIM_FUNCTION_TYPES_HPP_
#include "KIM_FunctionTypes.hpp" // IWYU pragma: export
#endif
namespace KIM
{
// Forward declarations
class LogVerbosity;
class LanguageName;
class LogImplementation;
/// \brief Provides the logging interface for the %KIM API.
///
/// \sa KIM_Log, kim_log_module::kim_log_handle_type
///
/// \since 2.0
class Log
{
public:
/// \brief Create a new %KIM API Log object.
///
/// \param[out] log Pointer to the newly created Log object.
///
/// \return \c false
///
/// \sa KIM_Log_Create, kim_log_module::kim_log_create
///
/// \since 2.0
static int Create(Log ** const log);
/// \brief Destroy a previously Log::Create'd object.
///
/// \param[inout] log Pointer to the Log object.
///
/// \pre \c log points to a previously created %KIM API Log object.
///
/// \post `log == NULL`.
///
/// \sa KIM_Log_Destroy, kim_log_module::kim_log_destroy
///
/// \since 2.0
static void Destroy(Log ** const log);
/// \brief Push a new default LogVerbosity onto the %KIM API global default
/// verbosity stack.
///
/// The default LogVerbosity is used when creating new Log objects.
///
/// \param[in] logVerbosity A LogVerbosity value.
///
/// \sa KIM_Log_PushDefaultVerbosity,
/// kim_log_module::kim_push_default_verbosity
///
/// \since 2.0
static void PushDefaultVerbosity(LogVerbosity const logVerbosity);
/// \brief Pop a LogVerbosity from the %KIM API global default verbosity
/// stack.
///
/// \sa KIM_Log_PopDefaultVerbosity,
/// kim_log_module::kim_pop_default_verbosity
///
/// \since 2.0
static void PopDefaultVerbosity();
/// \brief Push a new default log PrintFunction onto the %KIM API global
/// default log PrintFunction stack.
///
/// The default log PrintFunction is used when creating new Log objects.
///
/// \param[in] languageName The LanguageName of the function.
/// \param[in] fptr The function pointer.
///
/// \sa KIM_Log_PushDefaultPrintFunction,
/// kim_log_module::kim_push_default_print_function
///
/// \since 2.2
static void PushDefaultPrintFunction(LanguageName const languageName,
Function * const fptr);
/// \brief Pop a log PrintFunction from the %KIM API global default log
/// PrintFunction stack.
///
/// \sa KIM_Log_PopDefaultPrintFunction,
/// kim_log_module::kim_pop_default_print_function
///
/// \since 2.2
static void PopDefaultPrintFunction();
/// \brief Get the identity of the Log object.
///
/// \sa KIM_Log_GetID, kim_log_module::kim_get_id
///
/// \since 2.0
std::string const & GetID() const;
/// \brief Set the identity of the Log object.
///
/// \param[in] id String identifying the Log object.
///
/// \sa KIM_Log_SetID, kim_log_module::kim_set_id
///
/// \since 2.0
void SetID(std::string const & id);
/// \brief Push a new LogVerbosity onto the Log object's verbosity stack.
///
/// \param[in] logVerbosity A LogVerbosity value.
///
/// \sa KIM_Log_PushVerbosity, kim_log_module::kim_push_verbosity
///
/// \since 2.0
void PushVerbosity(LogVerbosity const logVerbosity);
/// \brief Pop a LogVerbosity from the Log object's verbosity stack.
///
/// \sa KIM_Log_PopVerbosity, kim_log_module::kim_pop_verbosity
///
/// \since 2.0
void PopVerbosity();
/// \brief Write a log entry into the log file.
///
/// This results in a no-op if \c logVerbosity is LOG_VERBOSITY::silent or if
/// \c logVerbosity is greater-than the Log object's top LogVerbosity on its
/// stack.
///
/// \param[in] logVerbosity The LogVerbosity level for the entry.
/// \param[in] message The body text of the log entry.
/// \param[in] lineNumber The source code file line number.
/// \param[in] fileName The source code file name.
///
/// \sa KIM_Log_LogEntry, kim_log_module::kim_log_entry
///
/// \since 2.0
void LogEntry(LogVerbosity const logVerbosity,
std::string const & message,
int const lineNumber,
std::string const & fileName) const;
/// \overload
void LogEntry(LogVerbosity const logVerbosity,
std::stringstream const & message,
int const lineNumber,
std::string const & fileName) const;
private:
// do not allow copy constructor or operator=
Log(Log const &);
void operator=(Log const &);
Log();
~Log();
LogImplementation * pimpl;
}; // class Log
} // namespace KIM
#endif // KIM_LOG_HPP_
|