Files
kwa.fr/src/misc/logConsoleGUI/logConsoleGUI.h
2026-03-12 16:32:03 +01:00

92 lines
3.9 KiB
C++

/* --- logConsoleGUI.h -----------------------------------------
System: Log system for gui applications
Status: Version 1.0 Release 2
Language: C++
(c) Copyright SD-Innovation 2016
Address:
SD-INNOVATION SAS
Site Eiffel Energie / ZAC Ban La Dame
48, square Eugène Herzog
54390 FROUARD
FRANCE
Author: Sylvain Schneider
E-Mail: s.schneider@sd-innovation.fr
Description: Header file for logConsoleGUI
This class allows you to attach GUI application to text console
or file to write log informations.
Thread Safe: No
Platform Dependencies: None (i.e.: Linux/Intel, IRIX/Mips, Solaris/SPARC)
Compiler Options:
Change History:
Date Author Description
2016-09-28 Sylvain Schneider Closing the console window when it released
2016-08-23 Sylvain Schneider First version
------------------------------------------------------------- */
#ifndef LOGCONSOLEGUI_H
#define LOGCONSOLEGUI_H
#include <iostream>
#include <fstream>
#include <memory>
#include <stdint.h>
enum e_logLevel
{
level_DEBUG_COMMUNICATION, // Information useful to developers for debugging the communication application
level_DEBUG, // Information useful to developers for debugging the application
level_INFORMATIONS, // Normal operational messages that require no action (An application has started, paused or ended successfully)
level_NOTICE, // Events that are unusual, but not error conditions
level_WARNING, // May indicate that an error will occur if action is not taken
level_ERROR, // Error conditions
level_CRITICAL, // Critical conditions
level_ALERT, // Should be corrected immediately
level_EMERGENCY, // Application is unusable
};
namespace sdiTools
{
//--------------------------------------------------------------
class logConsoleGUI
{
public:
public:
logConsoleGUI(const std::string &logFilepath = ""); // Constructor
virtual ~logConsoleGUI(); // Destructor
void openLogFile(const std::string &logFilepath); // Open log file
void closeLogFile(); // Close log file
int64_t getLogFileSize(); // Return opened log file size
void initConsole(bool attachOnly = false); // Init application console
void releaseConsole(); // Release application console
bool hasAttachedConsole(); // Returns true if console was attached, false otherwise
void disable_quickEditMode();
void alwaysOnTop();
void log(const std::string &msg, // Log message into console and log file
e_logLevel level = level_INFORMATIONS);
virtual std::string header(); // Define header to console log
private:
std::ofstream m_logFile;
FILE *m_stdoutFile = nullptr;
FILE *m_stderrFile = nullptr;
};
//--------------------------------------------------------------
} // namespace sdiTools
typedef std::unique_ptr<sdiTools::logConsoleGUI> t_logConsoleGUI;
extern t_logConsoleGUI logConsole;
#endif // LOGCONSOLEGUI_H