Deskflow
1.26.0.418
Keyboard and mouse sharing utility
Toggle main menu visibility
Loading...
Searching...
No Matches
Log.h
Go to the documentation of this file.
1
/*
2
* Deskflow -- mouse and keyboard sharing utility
3
* SPDX-FileCopyrightText: (C) 2026 Deskflow Developers.
4
* SPDX-FileCopyrightText: (C) 2012 - 2016 Synergy App Ltd
5
* SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
6
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
7
*/
8
9
#pragma once
10
11
#include "
common/LogLevel.h
"
12
13
#include <list>
14
#include <mutex>
15
16
#include <QString>
17
18
#define CLOG (Log::getInstance())
19
#define BYE "\nTry `%s --help' for more information."
20
21
class
ILogOutputter
;
22
class
Thread
;
23
25
31
class
Log
32
{
33
public
:
34
explicit
Log
(
bool
singleton =
true
);
35
explicit
Log
(
Log
*src);
36
Log
(
Log
const
&) =
delete
;
37
Log
(
Log
&&) =
delete
;
38
~Log
();
39
40
Log
&
operator=
(
Log
const
&) =
delete
;
41
Log
&
operator=
(
Log
&&) =
delete
;
42
44
45
47
63
void
insert
(
ILogOutputter
*adoptedOutputter,
bool
alwaysAtHead =
false
);
64
66
71
void
remove
(
ILogOutputter
*orphaned);
72
74
79
void
pop_front
(
bool
alwaysAtHead =
false
);
80
82
89
bool
setFilter
(
const
QString &
name
);
90
92
void
setFilter
(
LogLevel::Level
);
93
95
97
99
104
void
print
(
const
char
*file,
int
line,
const
char
*format, ...);
105
107
LogLevel::Level
getFilter
()
const
;
108
110
static
Log
*
getInstance
();
111
114
LogLevel::Level
getConsoleMaxLevel
()
const
115
{
116
return
LogLevel::Level::Verbose
;
117
}
118
120
121
private
:
122
void
output(
LogLevel::Level
priority,
const
char
*msg);
123
124
private
:
125
using
OutputterList = std::list<ILogOutputter *>;
126
127
static
Log
*s_log;
128
129
mutable
std::mutex m_mutex;
130
OutputterList m_outputters;
131
OutputterList m_alwaysOutputters;
132
LogLevel::Level
m_maxPriority;
133
};
134
153
173
174
#if defined(NOLOGGING)
175
#define LOG(_a1)
176
#define LOGC(_a1, _a2)
177
#define CLOG_TRACE
178
#elif defined(NDEBUG)
179
#define LOG(_a1) CLOG->print _a1
180
#define LOGC(_a1, _a2) \
181
if (_a1) \
182
CLOG->print _a2
183
#define CLOG_TRACE nullptr, 0,
184
#else
185
#define LOG(_a1) CLOG->print _a1
186
#define LOGC(_a1, _a2) \
187
if (_a1) \
188
CLOG->print _a2
189
#define CLOG_TRACE __FILE__, __LINE__,
190
#endif
191
192
// the CLOG_* defines are line and file plus %z and an octal number (060=0,
193
// 071=9), but the limitation is that once we run out of numbers at either
194
// end, then we resort to using non-numerical chars. this still works (since
195
// to deduce the number we subtract octal \060, so '/' is -1, and ':' is 10
196
197
// Priority tag used as the first three bytes of a format string. Log::print
198
// reads fmt[2] - '0' to recover the level, so the escape must be ASCII '0'-'9'.
199
#define CLOG_TAG_PRINT "%z\057"
// char is '/'
200
#define CLOG_TAG_CRIT "%z\060"
// char is '0'
201
#define CLOG_TAG_ERR "%z\061"
202
#define CLOG_TAG_WARN "%z\062"
203
#define CLOG_TAG_INFO "%z\063"
204
#define CLOG_TAG_DEBUG "%z\064"
205
#define CLOG_TAG_VERBOSE "%z\065"
206
207
#define CLOG_PRINT CLOG_TRACE CLOG_TAG_PRINT
208
#define CLOG_CRIT CLOG_TRACE CLOG_TAG_CRIT
209
#define CLOG_ERR CLOG_TRACE CLOG_TAG_ERR
210
#define CLOG_WARN CLOG_TRACE CLOG_TAG_WARN
211
#define CLOG_INFO CLOG_TRACE CLOG_TAG_INFO
212
#define CLOG_DEBUG CLOG_TRACE CLOG_TAG_DEBUG
213
#define CLOG_VERBOSE CLOG_TRACE CLOG_TAG_VERBOSE
214
215
#define LOG_PRINT(...) LOG((CLOG_PRINT __VA_ARGS__))
216
#define LOG_CRIT(...) LOG((CLOG_CRIT __VA_ARGS__))
217
#define LOG_ERR(...) LOG((CLOG_ERR __VA_ARGS__))
218
#define LOG_WARN(...) LOG((CLOG_WARN __VA_ARGS__))
219
#define LOG_INFO(...) LOG((CLOG_INFO __VA_ARGS__))
220
#define LOG_DEBUG(...) LOG((CLOG_DEBUG __VA_ARGS__))
221
#define LOG_VERBOSE(...) LOG((CLOG_VERBOSE __VA_ARGS__))
name
static const struct sockaddr FAR * name
Definition
ArchNetworkWinsock.cpp:29
LogLevel.h
ILogOutputter
Outputter interface.
Definition
ILogOutputter.h:21
LogLevel::Level
Level
Log levels.
Definition
LogLevel.h:22
LogLevel::Level::Verbose
@ Verbose
For verbose debugging messages.
Definition
LogLevel.h:29
Log
Logging facility.
Definition
Log.h:32
Log::print
void print(const char *file, int line, const char *format,...)
Print a log message.
Definition
Log.cpp:143
Log::getConsoleMaxLevel
LogLevel::Level getConsoleMaxLevel() const
Definition
Log.h:114
Log::insert
void insert(ILogOutputter *adoptedOutputter, bool alwaysAtHead=false)
Add an outputter to the head of the list and adopts it.
Definition
Log.cpp:180
Log::getFilter
LogLevel::Level getFilter() const
Get the minimum priority level.
Definition
Log.cpp:226
Log::Log
Log(Log &&)=delete
Log::getInstance
static Log * getInstance()
Get the singleton instance of the log.
Definition
Log.cpp:137
Log::operator=
Log & operator=(Log const &)=delete
Log::operator=
Log & operator=(Log &&)=delete
Log::Log
Log(bool singleton=true)
Definition
Log.cpp:106
Log::pop_front
void pop_front(bool alwaysAtHead=false)
Remove the outputter from the head of the list.
Definition
Log.cpp:201
Log::setFilter
bool setFilter(const QString &name)
Set the minimum priority filter.
Definition
Log.cpp:211
Log::Log
Log(Log const &)=delete
Log::remove
void remove(ILogOutputter *orphaned)
Remove an outputter from the list.
Definition
Log.cpp:194
Thread
Thread handle.
Definition
Thread.h:33
src
lib
base
Log.h
Generated by
1.18.0