mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Add WrappedSink
This commit is contained in:
@@ -998,6 +998,8 @@
|
||||
<ClCompile Include="..\..\src\beast\beast\utility\Utility.unity.cpp">
|
||||
<ExcludedFromBuild>True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClInclude Include="..\..\src\beast\beast\utility\WrappedSink.h">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\beast\utility\Zero.h">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\beast\Version.h">
|
||||
|
||||
@@ -1686,6 +1686,9 @@
|
||||
<ClCompile Include="..\..\src\beast\beast\utility\Utility.unity.cpp">
|
||||
<Filter>beast\utility</Filter>
|
||||
</ClCompile>
|
||||
<ClInclude Include="..\..\src\beast\beast\utility\WrappedSink.h">
|
||||
<Filter>beast\utility</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\beast\utility\Zero.h">
|
||||
<Filter>beast\utility</Filter>
|
||||
</ClInclude>
|
||||
|
||||
89
src/beast/beast/utility/WrappedSink.h
Normal file
89
src/beast/beast/utility/WrappedSink.h
Normal file
@@ -0,0 +1,89 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef BEAST_UTILITY_WRAPPED_SINK_H_INCLUDED
|
||||
#define BEAST_UTILITY_WRAPPED_SINK_H_INCLUDED
|
||||
|
||||
#include <beast/utility/Journal.h>
|
||||
|
||||
namespace beast {
|
||||
|
||||
/** Wraps a Journal::Sink to prefix its output with a string. */
|
||||
class WrappedSink : public beast::Journal::Sink
|
||||
{
|
||||
private:
|
||||
std::string prefix_;
|
||||
beast::Journal::Sink& sink_;
|
||||
|
||||
public:
|
||||
explicit
|
||||
WrappedSink (beast::Journal::Sink& sink)
|
||||
: sink_ (sink)
|
||||
{
|
||||
}
|
||||
|
||||
explicit
|
||||
WrappedSink (beast::Journal const& journal)
|
||||
: sink_ (journal.sink())
|
||||
{
|
||||
}
|
||||
|
||||
void prefix (std::string const& s)
|
||||
{
|
||||
prefix_ = s;
|
||||
}
|
||||
|
||||
bool
|
||||
active (beast::Journal::Severity level) const override
|
||||
{
|
||||
return sink_.active (level);
|
||||
}
|
||||
|
||||
bool
|
||||
console () const override
|
||||
{
|
||||
return sink_.console ();
|
||||
}
|
||||
|
||||
void console (bool output) override
|
||||
{
|
||||
sink_.console (output);
|
||||
}
|
||||
|
||||
beast::Journal::Severity
|
||||
severity() const
|
||||
{
|
||||
return sink_.severity();
|
||||
}
|
||||
|
||||
void severity (beast::Journal::Severity level)
|
||||
{
|
||||
sink_.severity (level);
|
||||
}
|
||||
|
||||
void write (beast::Journal::Severity level, std::string const& text)
|
||||
{
|
||||
using beast::Journal;
|
||||
sink_.write (level, prefix_ + text);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -39,6 +39,7 @@
|
||||
#include <beast/asio/ssl_bundle.h>
|
||||
#include <beast/http/message.h>
|
||||
#include <beast/http/parser.h>
|
||||
#include <beast/utility/WrappedSink.h>
|
||||
#include <cstdint>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
Reference in New Issue
Block a user