1/** \page reference.logging Logging Reference 2 3WebSocket++ has the capability of logging events during the lifetime of the connections that it processes. Each endpoint has two independent logging interfaces that are used by all connections created by that endpoint. The first is an access interface that allows logging routine events in the life of a connection (such as connect/disconnect and receipt of messages). The other is an error interface that allows logging non-routine problems or errors. Each interface has a number of different named channels that can be toggled on and off independently. 4 5Exactly how these logs are processed and where they are written to depends on which logging policy is in use. Several logging policies are included by default and you can write your own policy if you need something more specialized. Selecting a policy is done via the \subpage reference.config "endpoint config". 6 7Common functionality (all policies) 8----------------------------------- 9 10### Logging Channels 11 12Each logging interface is divided into 32 named channels. Log messages are written to a specific interface on a specific channel. Which log messages are actually printed is determined by which channels are enabled or not. Channels can be enabled or disabled either at compile time or at runtime. 13 14### Enabling and Disabling Channels 15 16Channels disabled at compile time are removed from the code entirely (assuming correct compiler optimization settings) and are not available for runtime enabling or disabling. To disable channels at compile time, use the `alog_level` and `elog_level` values within your \subpage reference.config "endpoint config". Channels not disabled at compile time can be enabled or disabled at runtime using the `websocketpp::endpoint::set_access_channels()`, `websocketpp::endpoint::clear_access_channels()`, `websocketpp::endpoint::set_error_channels()`, and `websocketpp::endpoint::clear_error_channels()` methods. 17 18The set and clear functions act only on the channels specified. `set_access_channels(log::alevel::connect)` will enable logging of new connections. Following this with `set_access_channels(log::alevel::disconnect)` will enable logging of disconnections in addition to connections. Use `clear*` functions to disable a specific channel. Channels may be combined using bitwise operations to create aggregate packages of channels that may be set or cleared at once. Default packages include `websocketpp::log::alevel::all`, `websocketpp::log::elevel::all`, `websocketpp::log::alevel::none`, `websocketpp::log::elevel::none`. These represent all possible access/error channels and no access/error channels respectively. For convenience, setting none is aliased to clearing all. 19 20### Examples 21 22__Disable all__ 23 24`clear_access_channels(log::alevel::all)` 25 26__Disable all (alternative method)__ 27 28`set_access_channels(log::alevel::none)` 29 30__Multiple channels at once__ 31 32`log::alevel::message_payload | log::alevel::message_payload` 33 34__All except one__ 35 36`log::alevel::all ^ log::alevel::message_payload` 37 38__Default settings__ 39 40By default, only debug/development logging is disabled. 41 42### Access to underlying loggers 43 44Logging interfaces may be directly accessed via their associated endpoint or connection using get_alog() and get_elog(). This allows access to methods specific to the chosen logging policy. 45 46Basic Logging (Default Policy) 47------------------------------ 48 49The basic logging policy (`websocketpp::log::basic`) writes logs to a std::ostream. By default, access logs are written to stdout and error logs are written to stderr. Each logging interface may be optionally redirected to an arbitrary C++ stream (including file streams) using the `websocketpp::log::basic::set_ostream()` method. 50 51Syslog Logging 52-------------- 53 54The syslog logging policy (`websocketpp::log::syslog`) logs to POSIX syslog. It is included in the header `<websocketpp/logger/syslog.hpp>`. It requires a system with `<syslog.h>`. 55 56Stub Logging 57------------ 58 59The stub logging policy (`websocketpp::log::stub`) implements the logging policy interface but ignores all input and provides no output. It can be used to stub out the logging system in tests or to completely disable and remove nearly all logging related code. 60 61The stub logger also provides documentation for the minimal required interface to build a custom logging policy. 62 63Log level reference 64------------------- 65 66### Error Logging Levels 67 68Each of these channels is in the namespace `websocketpp::log::elevel` 69 70| Level | Description | 71| ------- | -------------------------------------------------------------------------------------------------------------------------- | 72| none | Special aggregate value representing "no levels" | 73| devel | Low level debugging information (warning: very chatty). Requires debug or custom config. | 74| library | Information about unusual system states or other minor internal library problems, less chatty than devel. | 75| info | Information about minor configuration problems or additional information about other warnings. | 76| warn | Information about important problems not severe enough to terminate connections. | 77| rerror | Recoverable error. Recovery may mean cleanly closing the connection with an appropriate error code to the remote endpoint. | 78| fatal | Unrecoverable error. This error will trigger immediate unclean termination of the connection or endpoint. | 79| all | Special aggregate value representing "all levels" | 80 81### Access Logging Levels 82 83Each of these channels is in the namespace `websocketpp::log::alevel` 84 85| Level | Description | 86| --------------- | -------------------------------------------------------------------------------------------------- | 87| none | Special aggregate value representing "no levels" | 88| connect | One line for each new connection that includes a host of information including: the remote address, websocket version, requested resource, http code, remote user agent | 89| disconnect | One line for each connection that is closed. Includes closing codes and reasons | 90| control | One line per control message | 91| frame_header | One line per frame, includes the full frame header | 92| frame_payload | One line per frame, includes the full message payload (warning: lots of output for large messages) | 93| message_header | Reserved | 94| message_payload | Reserved | 95| endpoint | Reserved | 96| debug_handshake | Extra information about opening handshakes | 97| debug_close | Extra information about closing handshakes | 98| devel | Development messages (warning: very chatty). Requires debug or custom config. | 99| app | Special channel for application specific logs. Not used by the library. | 100| all | Special aggregate value representing "all levels" | 101 102*/ 103