21 #include "Typedefs.hpp" 37 class DLL_PUBLIC
LogStream :
public std::ostringstream
60 static const std::string sourceToString(
const Source& source);
84 static const std::string levelToString(Level level);
126 LogSink(
const std::string& name);
138 const std::string& name()
const;
178 void setEnabled(
bool state,
LogStream::Level level = LogStream::Level::Warning);
196 void setOutputConsole(
bool state);
205 void setOutputFile(
bool state,
const std::string& filepath = std::string(),
bool append =
true);
213 void setOutputSyslog(
bool state,
const std::string& ident = std::string());
221 void setAuditFile(
bool state,
const std::string& filepath);
228 void addOutputSink(std::unique_ptr<LogSink>& sink);
235 void delOutputSink(
const std::string& name);
266 static const std::string timestamp();
275 void addOutputSink_nolock(std::unique_ptr<LogSink>& sink);
282 void delOutputSink_nolock(
const std::string& name);
289 std::unique_lock<std::mutex> lock()
const;
291 mutable std::mutex _mutex;
294 std::map<std::string, std::unique_ptr<LogSink>> _sinks;
297 extern DLL_PUBLIC
Logger G_logger;
299 #if defined(__GNUC__) 300 #define USBGUARD_SOURCE_FILE __BASE_FILE__ 302 #define USBGUARD_SOURCE_FILE __FILE__ 305 #define USBGUARD_LOGGER usbguard::G_logger 307 #define USBGUARD_FUNCTION __func__ 309 #define USBGUARD_LOG(level) \ 310 if (USBGUARD_LOGGER.isEnabled(usbguard::LogStream::Level::level)) \ 311 USBGUARD_LOGGER(USBGUARD_SOURCE_FILE, __LINE__, USBGUARD_FUNCTION, usbguard::LogStream::Level::level) Logger.
Definition: Logger.hpp:156
Logger output sink.
Definition: Logger.hpp:117
std::string file
Definition: Logger.hpp:45
Contains information about the source.
Definition: Logger.hpp:44
Level
Log levels.
Definition: Logger.hpp:65
Generates audit events for given policy or device events.
Definition: Audit.hpp:233
int line
Definition: Logger.hpp:46
Log stream.
Definition: Logger.hpp:37