log.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. #ifndef _WX_PROTOCOL_LOG_H_
  10. #define _WX_PROTOCOL_LOG_H_
  11. #include "wx/string.h"
  12. // ----------------------------------------------------------------------------
  13. // wxProtocolLog: simple class for logging network requests and responses
  14. // ----------------------------------------------------------------------------
  15. class WXDLLIMPEXP_NET wxProtocolLog
  16. {
  17. public:
  18. // Create object doing the logging using wxLogTrace() with the specified
  19. // trace mask.
  20. wxProtocolLog(const wxString& traceMask)
  21. : m_traceMask(traceMask)
  22. {
  23. }
  24. // Virtual dtor for the base class
  25. virtual ~wxProtocolLog() { }
  26. // Called by wxProtocol-derived classes to actually log something
  27. virtual void LogRequest(const wxString& str)
  28. {
  29. DoLogString("==> " + str);
  30. }
  31. virtual void LogResponse(const wxString& str)
  32. {
  33. DoLogString("<== " + str);
  34. }
  35. protected:
  36. // Can be overridden by the derived classes.
  37. virtual void DoLogString(const wxString& str);
  38. private:
  39. const wxString m_traceMask;
  40. wxDECLARE_NO_COPY_CLASS(wxProtocolLog);
  41. };
  42. #endif // _WX_PROTOCOL_LOG_H_