1 ///////////////////////////////////////////////////////////////////////////////
2 // Name:        wx/protocol/log.h
3 // Purpose:     wxProtocolLog class for logging network exchanges
4 // Author:      Troelsk, Vadim Zeitlin
5 // Created:     2009-03-06
6 // Copyright:   (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
7 // Licence:     wxWindows licence
8 ///////////////////////////////////////////////////////////////////////////////
9 
10 #ifndef _WX_PROTOCOL_LOG_H_
11 #define _WX_PROTOCOL_LOG_H_
12 
13 #include "wx/string.h"
14 
15 // ----------------------------------------------------------------------------
16 // wxProtocolLog: simple class for logging network requests and responses
17 // ----------------------------------------------------------------------------
18 
19 class WXDLLIMPEXP_NET wxProtocolLog
20 {
21 public:
22     // Create object doing the logging using wxLogTrace() with the specified
23     // trace mask.
wxProtocolLog(const wxString & traceMask)24     wxProtocolLog(const wxString& traceMask)
25         : m_traceMask(traceMask)
26     {
27     }
28 
29     // Virtual dtor for the base class
~wxProtocolLog()30     virtual ~wxProtocolLog() { }
31 
32     // Called by wxProtocol-derived classes to actually log something
LogRequest(const wxString & str)33     virtual void LogRequest(const wxString& str)
34     {
35         DoLogString(wxASCII_STR("==> ") + str);
36     }
37 
LogResponse(const wxString & str)38     virtual void LogResponse(const wxString& str)
39     {
40         DoLogString(wxASCII_STR("<== ") + str);
41     }
42 
43 protected:
44     // Can be overridden by the derived classes.
45     virtual void DoLogString(const wxString& str);
46 
47 private:
48     const wxString m_traceMask;
49 
50     wxDECLARE_NO_COPY_CLASS(wxProtocolLog);
51 };
52 
53 #endif // _WX_PROTOCOL_LOG_H_
54 
55