Files
qt-migration-legatus/qt6-after/qt6-migrated-legatus/include/nglapplication/nglloggerhandler.h
T

89 lines
2.6 KiB
C++
Executable File

/**
* @RDE_HEADER@
* Logger handling stuff for NGL(Core|Gui)Application
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once
#include <QByteArray>
#include <QString>
#ifndef LOGGERHANDLER_EXPORT
# ifdef BUILD_STATIC_LIBRARIES
# define LOGGERHANDLER_EXPORT
# else
# if defined(MAKE_NGLCOREAPPLICATION_LIB) || defined(MAKE_NGLGUIAPPLICATION_LIB) || defined(MAKE_NGLAPPLICATION_LIB) || defined(MAKE_NGLSINGLECOREAPPLICATION_LIB) || defined(MAKE_NGLSINGLEAPPLICATION_LIB)
# define LOGGERHANDLER_EXPORT Q_DECL_EXPORT
# else
# define LOGGERHANDLER_EXPORT Q_DECL_IMPORT
# endif
# endif
#endif
namespace NGL
{
class INGLLogger;
class LOGGERHANDLER_EXPORT LoggerHandler
{
public:
LoggerHandler() = default;
~LoggerHandler() = default;
/**
* @brief Creates a NGL RootLogger instance, using baseName as the name for the base logger and configFileName for the .props file
* @param baseName the name of the service/application
* @param configFileName The file name with the logging informations
* @param checkTime the time (in seconds) to check for modifications of the file
*/
void createLogger(const QByteArray &baseName,
const char *configFileName,
bool quiet = false);
/**
* @brief Creates a NGL RootLogger instance, using <svcName>.main as the base logger name,
* configFileName is created with 'log4cxx_<svcNameLowerCase>.props'
* @param baseName the name of the service/application
* @param exerciseId the (optional) exercise id, if > 0,
* @param additionalId an (optional) id to be used for logfile name creation,
* the output log name is created with ${USER}_<svcNameLowerCase>_<exerciseId>.log
*/
void createLogger(const QByteArray &baseName,
int exerciseId = 0,
int additionalId = 0,
bool quiet = false);
/**
* @brief get the base Logger created with createLogger()
*/
NGL::INGLLogger &baseLogger() const;
/**
* @brief Get a logger with the given name
* @param The logger to retrieve
*/
NGL::INGLLogger &logger(const char *loggerName) const;
/**
* @brief get the log filename postfix (e.g. /shd/CTC/log/ctc_foo)
*/
QString loggerNamePostfix() const { return m_loggerFilenamePostfix; }
/**
* @brief get the log filename prefix (e.g. .log)
*/
QString loggerNamePrefix() const { return m_loggerFilenamePrefix; }
/**
* @brief Retrieves the loggerhandler from ngl(core)application or nullptr
*/
static LoggerHandler *getLoggerHandler();
private:
QByteArray m_baseLoggerName;
QString m_loggerFilenamePostfix;
QString m_loggerFilenamePrefix;
};
} // namespace NGL