1
// Copyright 2010 Google Inc.
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
7
// http://www.apache.org/licenses/LICENSE-2.0
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
15
#ifndef MOD_SPDY_APACHE_LOG_MESSAGE_HANDLER_H_
16
#define MOD_SPDY_APACHE_LOG_MESSAGE_HANDLER_H_
21
#include "apr_pools.h"
23
#include "base/basictypes.h"
29
// Stack-allocate to install a server-specific log handler for the duration of
30
// the current scope (on the current thread only). For example:
32
// void SomeApacheHookFunction(server_rec* server) {
33
// ScopedServerLogHandler handler(server);
34
// ...call various other functions here...
37
// The log handler will be in effect until the end of the block, but only for
38
// this thread (even if this thread spawns other threads in the meantime).
39
// Establishing this server-specific log handler allows LOG() macros within
40
// called functions to produce better messages.
41
class ScopedServerLogHandler {
43
explicit ScopedServerLogHandler(server_rec* server);
44
~ScopedServerLogHandler();
46
DISALLOW_COPY_AND_ASSIGN(ScopedServerLogHandler);
49
// Stack-allocate to install a connection-specific log handler for the duration
50
// of the current scope (on the current thread only). See the doc comment for
51
// ScopedServerLogHandler above for an example.
52
class ScopedConnectionLogHandler {
54
explicit ScopedConnectionLogHandler(conn_rec* connection);
55
~ScopedConnectionLogHandler();
57
DISALLOW_COPY_AND_ASSIGN(ScopedConnectionLogHandler);
60
// Stack-allocate to install a stream-specific log handler for the duration of
61
// the current scope (on the current thread only). See the doc comment for
62
// ScopedServerLogHandler above for an example.
63
class ScopedStreamLogHandler {
65
explicit ScopedStreamLogHandler(conn_rec* slave_connection,
66
const SpdyStream* stream);
67
~ScopedStreamLogHandler();
69
DISALLOW_COPY_AND_ASSIGN(ScopedStreamLogHandler);
72
// Install a log message handler that routes LOG() messages to the
73
// apache error log. Should be called once, at server startup.
74
void InstallLogMessageHandler(apr_pool_t* pool);
76
// Set the logging level for LOG() messages, based on the Apache log level and
77
// the VLOG-level specified in the server config. Note that the VLOG level
78
// will be ignored unless the Apache log verbosity is at NOTICE or higher.
79
// Should be called once for each child process, at process startup.
80
void SetLoggingLevel(int apache_log_level, int vlog_level);
82
} // namespace mod_spdy
84
#endif // MOD_SPDY_APACHE_LOG_MESSAGE_HANDLER_H_