VR-Engage  2.2
Loading...
Searching...
No Matches
logger.h
Go to the documentation of this file.
1/*********************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4*********************************************************************************/
5
6#pragma once
7
8//! \file logger.h
9//! \brief Provides logging functionality with various severity levels and channels
10
11#include "vreUtil/export.h"
12
13#include <vlutil/vlPrint.h>
14
15//! \brief Macro to extract just the filename from a full path
16//!
17//! This macro extracts the filename from the full path in __FILE__
18//! Returns the filename without the directory path
19#define __FILENAME__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
20
21//! \brief Generates a timestamp string for log messages
22//!
23//! \return A formatted timestamp string for use in log messages
24std::string UTIL_DLL logTimestamp();
25
26//! \brief Logs a fatal error message
27//!
28//! \param channel The logging channel/category to use
29//! \param function The function name where the log originated
30//! \return An output stream to write the message to
31UTIL_DLL DtOutputStream& DtVreFatal(const std::string& channel, const std::string& function);
32
33//! \brief Logs a warning message
34//!
35//! \param channel The logging channel/category to use
36//! \param function The function name where the log originated
37//! \return An output stream to write the message to
38UTIL_DLL DtOutputStream& DtVreWarn(const std::string& channel, const std::string& function);
39
40//! \brief Logs an informational message
41//!
42//! \param channel The logging channel/category to use
43//! \param function The function name where the log originated
44//! \return An output stream to write the message to
45UTIL_DLL DtOutputStream& DtVreInfo(const std::string& channel, const std::string& function);
46
47//! \brief Logs a verbose message (more detailed than info)
48//!
49//! \param channel The logging channel/category to use
50//! \param function The function name where the log originated
51//! \return An output stream to write the message to
52UTIL_DLL DtOutputStream& DtVreVerbose(const std::string& channel, const std::string& function);
53
54//! \brief Logs a debug message
55//!
56//! \param channel The logging channel/category to use
57//! \param function The function name where the log originated
58//! \return An output stream to write the message to
59UTIL_DLL DtOutputStream& DtVreDebug(const std::string& channel, const std::string& function);
60
61//! \brief Macro to log a fatal message to log files
62//!
63//! \param channel The logging channel/category to use
64#define LOG_FATAL(channel) DtVreFatal(channel, __FUNCTION__)
65
66//! \brief Macro to log a warning message to log files
67//!
68//! \param channel The logging channel/category to use
69#define LOG_WARN(channel) DtVreWarn(channel, __FUNCTION__)
70
71//! \brief Macro to log an informational message to log files
72//!
73//! \param channel The logging channel/category to use
74#define LOG_INFO(channel) DtVreInfo(channel, __FUNCTION__)
75
76//! \brief Macro to log a verbose message to log files
77//!
78//! \param channel The logging channel/category to use
79#define LOG_VERBOSE(channel) DtVreVerbose(channel, __FUNCTION__)
80
81//! \brief Macro to log a debug message to log files
82//!
83//! \param channel The logging channel/category to use
84#define LOG_DEBUG(channel) DtVreDebug(channel, __FUNCTION__)
85
86//! \brief Macro to log a fatal message to an entity's object console
87//!
88//! \param channel The logging channel/category to use
89#define OBJCON_FATAL(channel) \
90 entity()->objectConsoleError() << "FATAL[" << channel << "] " << logTimestamp() << " " << __FUNCTION__ << ": "
91
92//! \brief Macro to log a warning message to an entity's object console
93//!
94//! \param channel The logging channel/category to use
95#define OBJCON_WARN(channel) \
96 entity()->objectConsoleWarn() << "WARN[" << channel << "] " << logTimestamp() << " " << __FUNCTION__ << ": "
97
98//! \brief Macro to log an informational message to an entity's object console
99//!
100//! \param channel The logging channel/category to use
101#define OBJCON_INFO(channel) \
102 entity()->objectConsoleInfo() << "INFO[" << channel << "] " << logTimestamp() << " " << __FUNCTION__ << ": "
103
104//! \brief Macro to log a verbose message to an entity's object console
105//!
106//! \param channel The logging channel/category to use
107#define OBJCON_VERBOSE(channel) \
108 entity()->objectConsoleVerbose() << "VERBOSE[" << channel << "] " << logTimestamp() << " " << __FUNCTION__ << ": "
109
110//! \brief Macro to log a debug message to an entity's object console
111//!
112//! \param channel The logging channel/category to use
113#define OBJCON_DEBUG(channel) \
114 entity()->objectConsoleDebug() << "DEBUG[" << channel << "] " << logTimestamp() << " " << __FUNCTION__ << ": "
Defines export macros for the VREngage Utility library.
#define UTIL_DLL
Export/import macro for non-Windows platforms.
Definition export.h:39
UTIL_DLL DtOutputStream & DtVreInfo(const std::string &channel, const std::string &function)
Logs an informational message.
std::string UTIL_DLL logTimestamp()
Generates a timestamp string for log messages.
UTIL_DLL DtOutputStream & DtVreDebug(const std::string &channel, const std::string &function)
Logs a debug message.
UTIL_DLL DtOutputStream & DtVreWarn(const std::string &channel, const std::string &function)
Logs a warning message.
UTIL_DLL DtOutputStream & DtVreVerbose(const std::string &channel, const std::string &function)
Logs a verbose message (more detailed than info)
UTIL_DLL DtOutputStream & DtVreFatal(const std::string &channel, const std::string &function)
Logs a fatal error message.