Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
system_message_handler.h
Go to the documentation of this file.
1 /*
2  * Copyright 2014 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http:///www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
18 
19 #ifndef PAGESPEED_SYSTEM_SYSTEM_MESSAGE_HANDLER_H_
20 #define PAGESPEED_SYSTEM_SYSTEM_MESSAGE_HANDLER_H_
21 
22 #include <cstdarg>
23 
31 
32 namespace net_instaweb {
33 
34 class AbstractMutex;
35 class Timer;
36 class Writer;
37 
41  public:
43 
44  virtual ~SystemMessageHandler();
45 
49  void set_buffer(Writer* buff);
50 
51  void SetPidString(const int64 pid) {
52  pid_string_ = StrCat("[", Integer64ToString(pid), "]");
53  }
54 
56  virtual bool Dump(Writer* writer);
57 
58  protected:
60  void AddMessageToBuffer(MessageType type, StringPiece formatted_message);
61  void AddMessageToBuffer(MessageType type, const char* file, int line,
62  StringPiece formatted_message);
63 
66  virtual void MessageVImpl(MessageType type, const char* msg, va_list args);
67  virtual void FileMessageVImpl(MessageType type, const char* file,
68  int line, const char* msg, va_list args);
69 
70  private:
71  friend class SystemMessageHandlerTest;
72 
75  Timer* timer_;
77  Writer* buffer_;
82  GoogleMessageHandler internal_handler_;
83  GoogleString pid_string_;
84  NullMessageHandler null_handler_;
85 
86 
87 };
88 
89 }
90 
91 #endif
Implementation of a message handler that does nothing.
Definition: null_message_handler.h:31
virtual void MessageVImpl(MessageType type, const char *msg, va_list args)
Abstract interface for implementing a mutex.
Definition: abstract_mutex.h:28
Definition: scoped_ptr.h:30
std::string GoogleString
PAGESPEED_KERNEL_BASE_STRING_H_.
Definition: string.h:24
void AddMessageToBuffer(MessageType type, StringPiece formatted_message)
Add messages to the SharedCircularBuffer.
virtual bool Dump(Writer *writer)
Dump contents of SharedCircularBuffer.
Interface for writing bytes to an output stream.
Definition: writer.h:29
Definition: system_message_handler.h:40
Timer interface, made virtual so it can be mocked for tests.
Definition: timer.h:27
Definition: google_message_handler.h:35