mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-20 02:55:50 +00:00
Journal option to write to Output window (MSVC)
This commit is contained in:
@@ -105,6 +105,7 @@ public:
|
|||||||
Sink& m_sink;
|
Sink& m_sink;
|
||||||
Severity const m_severity;
|
Severity const m_severity;
|
||||||
std::ostringstream mutable m_ostream;
|
std::ostringstream mutable m_ostream;
|
||||||
|
bool m_toOutputWindow;
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
@@ -122,6 +123,12 @@ public:
|
|||||||
/** Returns `true` if the sink logs messages at the severity of this stream. */
|
/** Returns `true` if the sink logs messages at the severity of this stream. */
|
||||||
bool active() const;
|
bool active() const;
|
||||||
|
|
||||||
|
/** Returns `true` if the stream also loggs messages to the Output window. */
|
||||||
|
bool toOutputWindow() const;
|
||||||
|
|
||||||
|
/** Also outputs Stream messages to the Output window (MSVC-specific). */
|
||||||
|
void setOutputWindow (bool toOutputWindow) const;
|
||||||
|
|
||||||
Sink& sink() const;
|
Sink& sink() const;
|
||||||
Severity severity() const;
|
Severity severity() const;
|
||||||
|
|
||||||
@@ -136,6 +143,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
Sink* m_sink;
|
Sink* m_sink;
|
||||||
Severity m_severity;
|
Severity m_severity;
|
||||||
|
bool mutable m_toOutputWindow;
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
@@ -151,6 +159,9 @@ public:
|
|||||||
/** Returns `true` if the sink logs messages at that severity. */
|
/** Returns `true` if the sink logs messages at that severity. */
|
||||||
bool active (Severity severity) const;
|
bool active (Severity severity) const;
|
||||||
|
|
||||||
|
/** Sets all streams to also log to the Output window (MSVC-specific). */
|
||||||
|
void setOutputWindow (bool toOutputWindow) const;
|
||||||
|
|
||||||
/** Convenience sink streams for each severity level. */
|
/** Convenience sink streams for each severity level. */
|
||||||
Stream const trace;
|
Stream const trace;
|
||||||
Stream const debug;
|
Stream const debug;
|
||||||
|
|||||||
@@ -54,18 +54,21 @@ Journal::Sink& Journal::getNullSink ()
|
|||||||
Journal::ScopedStream::ScopedStream (Stream const& stream)
|
Journal::ScopedStream::ScopedStream (Stream const& stream)
|
||||||
: m_sink (stream.sink())
|
: m_sink (stream.sink())
|
||||||
, m_severity (stream.severity())
|
, m_severity (stream.severity())
|
||||||
|
, m_toOutputWindow (stream.toOutputWindow())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Journal::ScopedStream::ScopedStream (ScopedStream const& other)
|
Journal::ScopedStream::ScopedStream (ScopedStream const& other)
|
||||||
: m_sink (other.m_sink)
|
: m_sink (other.m_sink)
|
||||||
, m_severity (other.m_severity)
|
, m_severity (other.m_severity)
|
||||||
|
, m_toOutputWindow (other.m_toOutputWindow)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Journal::ScopedStream::ScopedStream (Stream const& stream, std::ostream& manip (std::ostream&))
|
Journal::ScopedStream::ScopedStream (Stream const& stream, std::ostream& manip (std::ostream&))
|
||||||
: m_sink (stream.sink())
|
: m_sink (stream.sink())
|
||||||
, m_severity (stream.severity())
|
, m_severity (stream.severity())
|
||||||
|
, m_toOutputWindow (stream.toOutputWindow())
|
||||||
{
|
{
|
||||||
m_ostream << manip;
|
m_ostream << manip;
|
||||||
}
|
}
|
||||||
@@ -77,6 +80,11 @@ Journal::ScopedStream::~ScopedStream ()
|
|||||||
if (! m_ostream.str().empty())
|
if (! m_ostream.str().empty())
|
||||||
m_sink.write (m_severity, m_ostream.str());
|
m_sink.write (m_severity, m_ostream.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if BEAST_MSVC
|
||||||
|
if (m_toOutputWindow && beast_isRunningUnderDebugger ())
|
||||||
|
Logger::outputDebugString (m_ostream.str());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostream& Journal::ScopedStream::operator<< (std::ostream& manip (std::ostream&)) const
|
std::ostream& Journal::ScopedStream::operator<< (std::ostream& manip (std::ostream&)) const
|
||||||
@@ -94,18 +102,21 @@ std::ostringstream& Journal::ScopedStream::ostream () const
|
|||||||
Journal::Stream::Stream ()
|
Journal::Stream::Stream ()
|
||||||
: m_sink (&getNullSink ())
|
: m_sink (&getNullSink ())
|
||||||
, m_severity (kFatal)
|
, m_severity (kFatal)
|
||||||
|
, m_toOutputWindow (false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Journal::Stream::Stream (Sink& sink, Severity severity)
|
Journal::Stream::Stream (Sink& sink, Severity severity)
|
||||||
: m_sink (&sink)
|
: m_sink (&sink)
|
||||||
, m_severity (severity)
|
, m_severity (severity)
|
||||||
|
, m_toOutputWindow (false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Journal::Stream::Stream (Stream const& other)
|
Journal::Stream::Stream (Stream const& other)
|
||||||
: m_sink (other.m_sink)
|
: m_sink (other.m_sink)
|
||||||
, m_severity (other.m_severity)
|
, m_severity (other.m_severity)
|
||||||
|
, m_toOutputWindow (other.m_toOutputWindow)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,6 +125,16 @@ bool Journal::Stream::active () const
|
|||||||
return m_sink->active (m_severity);
|
return m_sink->active (m_severity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Journal::Stream::toOutputWindow() const
|
||||||
|
{
|
||||||
|
return m_toOutputWindow;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Journal::Stream::setOutputWindow (bool toOutputWindow) const
|
||||||
|
{
|
||||||
|
m_toOutputWindow = toOutputWindow;
|
||||||
|
}
|
||||||
|
|
||||||
Journal::Sink& Journal::Stream::sink () const
|
Journal::Sink& Journal::Stream::sink () const
|
||||||
{
|
{
|
||||||
return *m_sink;
|
return *m_sink;
|
||||||
@@ -186,4 +207,14 @@ bool Journal::active (Severity severity) const
|
|||||||
return m_sink->active (severity);
|
return m_sink->active (severity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Journal::setOutputWindow (bool toOutputWindow) const
|
||||||
|
{
|
||||||
|
trace.setOutputWindow (toOutputWindow);
|
||||||
|
debug.setOutputWindow (toOutputWindow);
|
||||||
|
info.setOutputWindow (toOutputWindow);
|
||||||
|
warning.setOutputWindow (toOutputWindow);
|
||||||
|
fatal.setOutputWindow (toOutputWindow);
|
||||||
|
trace.setOutputWindow (toOutputWindow);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -137,6 +137,7 @@ void LogSink::write (std::string const& line, bool toStdErr, ScopedLockType&)
|
|||||||
|
|
||||||
if (toStdErr)
|
if (toStdErr)
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
#if BEAST_MSVC
|
#if BEAST_MSVC
|
||||||
if (beast_isRunningUnderDebugger ())
|
if (beast_isRunningUnderDebugger ())
|
||||||
{
|
{
|
||||||
@@ -145,6 +146,7 @@ void LogSink::write (std::string const& line, bool toStdErr, ScopedLockType&)
|
|||||||
Logger::outputDebugString (line);
|
Logger::outputDebugString (line);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
std::cerr << line << std::endl;
|
std::cerr << line << std::endl;
|
||||||
|
|||||||
Reference in New Issue
Block a user