SGCT
master (487fac4)
Simple Graphics Cluster Toolkit
Toggle main menu visibility
Loading...
Searching...
No Matches
log.h
Go to the documentation of this file.
1
/*****************************************************************************************
2
* SGCT *
3
* Simple Graphics Cluster Toolkit *
4
* *
5
* Copyright (c) 2012-2026 *
6
* For conditions of distribution and use, see copyright notice in LICENSE.md *
7
****************************************************************************************/
8
9
#ifndef __SGCT__LOGGER__H__
10
#define __SGCT__LOGGER__H__
11
12
#include <sgct/sgctexports.h>
13
14
#include <functional>
15
#include <mutex>
16
#include <string>
17
#include <string_view>
18
#include <vector>
19
20
namespace
sgct
{
21
22
class
SGCT_EXPORT Log {
23
public
:
27
enum class
Level
{
Error
= 3,
Warning
= 2,
Info
= 1,
Debug
= 0 };
28
29
static
Log&
instance
();
30
static
void
destroy
();
31
32
static
void
Debug
(std::string_view message);
33
static
void
Warning
(std::string_view message);
34
static
void
Info
(std::string_view message);
35
static
void
Error
(std::string_view message);
36
40
void
setNotifyLevel
(
Level
nl);
41
45
void
setShowTime
(
bool
state);
46
50
void
setShowLogLevel
(
bool
state);
51
55
void
setLogToConsole
(
bool
state);
56
61
void
setLogCallback
(std::function<
void
(
Level
, std::string_view)> fn);
62
63
private
:
64
Log();
65
Log(
const
Log&) =
delete
;
66
Log(Log&&) =
delete
;
67
Log& operator=(
const
Log&) =
delete
;
68
Log& operator=(Log&&) =
delete
;
69
70
void
printv(
Level
level, std::string message);
71
72
static
Log* _instance;
73
74
std::vector<char> _parseBuffer;
75
76
Level
_level =
Level::Info
;
77
bool
_showTime =
false
;
78
bool
_showLevel =
true
;
79
bool
_logToConsole =
true
;
80
81
std::mutex _mutex;
82
83
std::function<void(
Level
, std::string_view)> _messageCallback;
84
};
85
86
}
// namespace sgct
87
88
#endif
// __SGCT__LOGGER__H__
sgct::Log::Debug
static void Debug(std::string_view message)
sgct::Log::setShowLogLevel
void setShowLogLevel(bool state)
Sets whether the log level should be displayed with each print message.
sgct::Log::setLogToConsole
void setLogToConsole(bool state)
Set if log to console should be enabled.
sgct::Log::setNotifyLevel
void setNotifyLevel(Level nl)
Set the notify level for displaying messages.
sgct::Log::Level
Level
Different notify levels for messages.
Definition
log.h:27
sgct::Log::Level::Info
@ Info
Definition
log.h:27
sgct::Log::instance
static Log & instance()
sgct::Log::setLogCallback
void setLogCallback(std::function< void(Level, std::string_view)> fn)
Set the callback that gets invoked for each log.
sgct::Log::setShowTime
void setShowTime(bool state)
Set whether time of day should be displayed with each print message.
sgct::Log::Warning
static void Warning(std::string_view message)
sgct::Log::Info
static void Info(std::string_view message)
sgct::Log::destroy
static void destroy()
sgct::Log::Error
static void Error(std::string_view message)
sgct
Definition
actions.h:16
sgct
log.h
Generated by
1.18.0