Wt  4.10.4
Public Member Functions | List of all members
Wt::WLogSink Class Referenceabstract

An abstract log sink. More...

#include <Wt/WLogSink.h>

Public Member Functions

virtual void log (const std::string &type, const std::string &scope, const std::string &message) const noexcept=0
 Logs a message. More...
 
virtual bool logging (const std::string &type, const std::string &scope) const noexcept
 Returns whether messages of the given type should be logged. More...
 

Detailed Description

An abstract log sink.

You can implement this to redirect Wt or Wt::Dbo's logging to another logging system.

For Wt, you can configure the logger on a WServer level using WServer::setCustomLogger(). For Wt::Dbo, you can configure the logger globally using Wt::Dbo::setCustomLogger().

See also
WServer::setCustomLogger()
Wt::Dbo::setCustomLogger()
Wt::Dbo::logToWt()

Member Function Documentation

◆ log()

virtual void Wt::WLogSink::log ( const std::string &  type,
const std::string &  scope,
const std::string &  message 
) const
pure virtualnoexcept

Logs a message.

Parameters
typeThe type of the log message (e.g. debug, info, ...)
scopeThe scope of the message (e.g. WWidget, wthttp, ...)
messageThe message itself (usually starts with the scope too)

◆ logging()

virtual bool Wt::WLogSink::logging ( const std::string &  type,
const std::string &  scope 
) const
virtualnoexcept

Returns whether messages of the given type should be logged.

Parameters
typeThe type of the log message (e.g. debug, info, ...)
scopeThe scope of the message (e.g. WWidget, wthttp, ...)

The default implementation always returns true. You can reimplement this as an optimization: if the underlying logger doesn't log messages of a certain type, then Wt does not need to generate the log message.