You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

124 lines
4.0 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. * Copyright (c) 2014, Peter Thorson. All rights reserved.
  3. *
  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.
  14. *
  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.
  25. *
  26. */
  27. #ifndef WEBSOCKETPP_LOGGER_STUB_HPP
  28. #define WEBSOCKETPP_LOGGER_STUB_HPP
  29. #include <string>
  30. #include <websocketpp/common/cpp11.hpp>
  31. #include <websocketpp/logger/levels.hpp>
  32. namespace websocketpp
  33. {
  34. namespace log
  35. {
  36. /// Stub logger that ignores all input
  37. class stub
  38. {
  39. public:
  40. /// Construct the logger
  41. /**
  42. * @param hint A channel type specific hint for how to construct the logger
  43. */
  44. explicit stub(channel_type_hint::value) {}
  45. /// Construct the logger
  46. /**
  47. * @param default_channels A set of channels to statically enable
  48. * @param hint A channel type specific hint for how to construct the logger
  49. */
  50. stub(level, channel_type_hint::value) {}
  51. _WEBSOCKETPP_CONSTEXPR_TOKEN_ stub() {}
  52. /// Dynamically enable the given list of channels
  53. /**
  54. * All operations on the stub logger are no-ops and all arguments are
  55. * ignored
  56. *
  57. * @param channels The package of channels to enable
  58. */
  59. void set_channels(level) {}
  60. /// Dynamically disable the given list of channels
  61. /**
  62. * All operations on the stub logger are no-ops and all arguments are
  63. * ignored
  64. *
  65. * @param channels The package of channels to disable
  66. */
  67. void clear_channels(level) {}
  68. /// Write a string message to the given channel
  69. /**
  70. * Writing on the stub logger is a no-op and all arguments are ignored
  71. *
  72. * @param channel The channel to write to
  73. * @param msg The message to write
  74. */
  75. void write(level, const std::string &) {}
  76. /// Write a cstring message to the given channel
  77. /**
  78. * Writing on the stub logger is a no-op and all arguments are ignored
  79. *
  80. * @param channel The channel to write to
  81. * @param msg The message to write
  82. */
  83. void write(level, const char *) {}
  84. /// Test whether a channel is statically enabled
  85. /**
  86. * The stub logger has no channels so all arguments are ignored and
  87. * `static_test` always returns false.
  88. *
  89. * @param channel The package of channels to test
  90. */
  91. _WEBSOCKETPP_CONSTEXPR_TOKEN_ bool static_test(level) const
  92. {
  93. return false;
  94. }
  95. /// Test whether a channel is dynamically enabled
  96. /**
  97. * The stub logger has no channels so all arguments are ignored and
  98. * `dynamic_test` always returns false.
  99. *
  100. * @param channel The package of channels to test
  101. */
  102. bool dynamic_test(level)
  103. {
  104. return false;
  105. }
  106. };
  107. } // namespace log
  108. } // namespace websocketpp
  109. #endif // WEBSOCKETPP_LOGGER_STUB_HPP