risc-v-tlm/inc/Log.h

77 lines
1.4 KiB
C
Raw Normal View History

2018-09-11 00:44:54 +08:00
/*!
\file Log.h
\brief Class to manage Log
\author Màrius Montón
\date Aug 2018
*/
// SPDX-License-Identifier: GPL-3.0-or-later
2018-09-11 00:44:54 +08:00
#ifndef LOG_H
#define LOG_H
#define SC_INCLUDE_DYNAMIC_PROCESSES
#include <string>
#include <fstream>
#include <sstream>
#include "systemc"
#include "tlm.h"
/**
* @brief Log management class
*
* Singleton class to be shared among all other classes
*/
class Log {
public:
enum LogLevel {
ERROR = 0, DEBUG, WARNING, INFO
} currentLogLevel;
2018-09-11 00:44:54 +08:00
/**
* @brief Constructor
* @return pointer to Log class
*/
static Log* getInstance();
2018-09-11 00:44:54 +08:00
/**
* @brief method to log some string
* @param msg mesasge string
* @param level level of the log (LogLevel)
*/
void SC_log(const std::string& msg, enum LogLevel level);
2018-09-11 00:44:54 +08:00
/**
* @brief method to log some string
* @param level level of the log (LogLevel)
* @return streaming
*
* This function can be used in the following way:
* \code
* my_log->SC_log(Log::WARNING) << "some warning text"
* \endcode
*/
std::ofstream& SC_log(enum LogLevel level);
2018-09-11 00:44:54 +08:00
/**
* @brief Sets log level
* @param newLevel Level of the log
*/
void setLogLevel(enum LogLevel newLevel);
2018-09-11 00:44:54 +08:00
2020-11-12 18:02:26 +08:00
/**
* @brief Returns log level
* @return Current log level
*/
enum LogLevel getLogLevel() const;
2018-09-11 00:44:54 +08:00
private:
static Log *instance;
2021-04-26 01:52:12 +08:00
explicit Log(const char *filename);
std::ofstream m_stream;
std::ofstream m_sink;
2018-09-11 00:44:54 +08:00
};
#endif