2 * Copyright (c) 2014, Peter Thorson. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the name of the WebSocket++ Project nor the
12 * names of its contributors may be used to endorse or promote products
13 * derived from this software without specific prior written permission.
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL PETER THORSON BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 #ifndef WEBSOCKETPP_LOGGER_LEVELS_HPP
29 #define WEBSOCKETPP_LOGGER_LEVELS_HPP
31 #include <websocketpp/common/stdint.hpp>
33 namespace websocketpp {
36 /// Type of a channel package
37 typedef uint32_t level;
39 /// Package of values for hinting at the nature of a given logger.
41 * Used by the library to signal to the logging class a hint that it can use to
42 * set itself up. For example, the `access` hint indicates that it is an access
43 * log that might be suitable for being printed to an access log file or to cout
44 * whereas `error` might be suitable for an error log file or cerr.
46 struct channel_type_hint {
47 /// Type of a channel type hint value
48 typedef uint32_t value;
51 static value const none = 0;
53 static value const access = 1;
55 static value const error = 2;
58 /// Package of log levels for logging errors
60 /// Special aggregate value representing "no levels"
61 static level const none = 0x0;
62 /// Low level debugging information (warning: very chatty)
63 static level const devel = 0x1;
64 /// Information about unusual system states or other minor internal library
65 /// problems, less chatty than devel.
66 static level const library = 0x2;
67 /// Information about minor configuration problems or additional information
68 /// about other warnings.
69 static level const info = 0x4;
70 /// Information about important problems not severe enough to terminate
72 static level const warn = 0x8;
73 /// Recoverable error. Recovery may mean cleanly closing the connection with
74 /// an appropriate error code to the remote endpoint.
75 static level const rerror = 0x10;
76 /// Unrecoverable error. This error will trigger immediate unclean
77 /// termination of the connection or endpoint.
78 static level const fatal = 0x20;
79 /// Special aggregate value representing "all levels"
80 static level const all = 0xffffffff;
82 /// Get the textual name of a channel given a channel id
84 * The id must be that of a single channel. Passing an aggregate channel
85 * package results in undefined behavior.
87 * @param channel The channel id to look up.
89 * @return The name of the specified channel.
91 static char const * channel_name(level channel) {
111 /// Package of log levels for logging access events
113 /// Special aggregate value representing "no levels"
114 static level const none = 0x0;
115 /// Information about new connections
117 * One line for each new connection that includes a host of information
118 * including: the remote address, websocket version, requested resource,
119 * http code, remote user agent
121 static level const connect = 0x1;
122 /// One line for each closed connection. Includes closing codes and reasons.
123 static level const disconnect = 0x2;
124 /// One line per control frame
125 static level const control = 0x4;
126 /// One line per frame, includes the full frame header
127 static level const frame_header = 0x8;
128 /// One line per frame, includes the full message payload (warning: chatty)
129 static level const frame_payload = 0x10;
131 static level const message_header = 0x20;
133 static level const message_payload = 0x40;
135 static level const endpoint = 0x80;
136 /// Extra information about opening handshakes
137 static level const debug_handshake = 0x100;
138 /// Extra information about closing handshakes
139 static level const debug_close = 0x200;
140 /// Development messages (warning: very chatty)
141 static level const devel = 0x400;
142 /// Special channel for application specific logs. Not used by the library.
143 static level const app = 0x800;
144 /// Access related to HTTP requests
145 static level const http = 0x1000;
146 /// One line for each failed WebSocket connection with details
147 static level const fail = 0x2000;
148 /// Aggregate package representing the commonly used core access channels
149 /// Connect, Disconnect, Fail, and HTTP
150 static level const access_core = 0x00003003;
151 /// Special aggregate value representing "all levels"
152 static level const all = 0xffffffff;
154 /// Get the textual name of a channel given a channel id
156 * Get the textual name of a channel given a channel id. The id must be that
157 * of a single channel. Passing an aggregate channel package results in
158 * undefined behavior.
160 * @param channel The channelid to look up.
162 * @return The name of the specified channel.
164 static char const * channel_name(level channel) {
173 return "frame_header";
175 return "frame_payload";
177 return "message_header";
178 case message_payload:
179 return "message_payload";
182 case debug_handshake:
183 return "debug_handshake";
185 return "debug_close";
189 return "application";
203 #endif //WEBSOCKETPP_LOGGER_LEVELS_HPP