20 #include <ripple/basics/Log.h>
21 #include <ripple/basics/chrono.h>
22 #include <ripple/basics/contract.h>
23 #include <boost/algorithm/string.hpp>
37 :
beast::Journal::
Sink(thresh, false), logs_(logs), partition_(partition)
47 logs_.write(level, partition_, text, console());
59 return m_stream !=
nullptr;
67 bool wasOpened =
false;
77 m_stream = std::move(stream);
102 if (m_stream !=
nullptr)
109 if (m_stream !=
nullptr)
134 return *result.first->second;
161 sink.second->threshold(thresh);
170 for (
auto const& [name, sink] :
sinks_)
183 format(s, text, level, partition);
199 return "The log file was closed and reopened.";
200 return "The log file could not be closed and reopened.";
206 return std::make_unique<Sink>(name,
threshold, *
this);
288 if (boost::iequals(s,
"trace"))
291 if (boost::iequals(s,
"debug"))
294 if (boost::iequals(s,
"info") || boost::iequals(s,
"information"))
297 if (boost::iequals(s,
"warn") || boost::iequals(s,
"warning") ||
298 boost::iequals(s,
"warnings"))
301 if (boost::iequals(s,
"error") || boost::iequals(s,
"errors"))
304 if (boost::iequals(s,
"fatal") || boost::iequals(s,
"fatals"))
317 output.
reserve(message.
size() + partition.size() + 100);
322 if (!partition.empty())
323 output += partition +
":";
362 auto scrubber = [&output](
char const* token) {
363 auto first = output.
find(token);
367 if (first != std::string::npos)
371 if (first != std::string::npos)
373 auto last = output.
find(
'\"', ++first);
375 if (last == std::string::npos)
376 last = output.
size();
378 output.
replace(first, last - first, last - first,
'*');
383 scrubber(
"\"seed\"");
384 scrubber(
"\"seed_hex\"");
385 scrubber(
"\"secret\"");
386 scrubber(
"\"master_key\"");
387 scrubber(
"\"master_seed\"");
388 scrubber(
"\"master_seed_hex\"");
389 scrubber(
"\"passphrase\"");
Abstraction for the underlying message destination.
std::vector< std::pair< std::string, std::string > > partition_severities() const
beast::severities::Severity thresh_
void close()
Close the system file if it is open.
Manages partitions for logging.
void writeln(char const *text)
write to the log file and append an end of line marker.
void write(char const *text)
write to the log file.
static DebugSink & debugSink()
A namespace for easy access to logging severity values.
File()
Construct with no associated system file.
beast::Journal::Sink & operator[](std::string const &name)
static Sink & getNullSink()
Returns a Sink which does nothing.
void write(beast::severities::Severity level, std::string const &text) override
Write text to the sink at the specified severity.
bool closeAndReopen()
Close and re-open the system file associated with the log This assists in interoperating with externa...
beast::Journal debugLog()
Returns a debug journal.
std::unique_ptr< beast::Journal::Sink > set(std::unique_ptr< beast::Journal::Sink > sink)
static std::string toString(LogSeverity s)
static LogSeverity fromSeverity(beast::severities::Severity level)
Logs & operator=(Logs const &)=delete
std::unique_ptr< beast::Journal::Sink > setDebugLogSink(std::unique_ptr< beast::Journal::Sink > sink)
Set the sink for the debug journal.
bool isOpen() const noexcept
Determine if a system file is associated with the log.
bool open(boost::filesystem::path const &path)
Associate a system file with the log.
static LogSeverity fromString(std::string const &s)
A generic endpoint for log messages.
Logs(beast::severities::Severity level)
beast::severities::Severity threshold() const
T emplace_back(T... args)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
beast::Journal journal(std::string const &name)
virtual std::unique_ptr< beast::Journal::Sink > makeSink(std::string const &partition, beast::severities::Severity startingLevel)
@ maximumMessageCharacters
Severity
Severity level / threshold of a Journal message.
beast::Journal::Sink & get()
std::reference_wrapper< beast::Journal::Sink > sink_
std::string to_string(Manifest const &m)
Format the specified manifest to a string for debugging purposes.
static beast::severities::Severity toSeverity(LogSeverity level)
std::unique_ptr< beast::Journal::Sink > holder_
std::map< std::string, std::unique_ptr< beast::Journal::Sink >, boost::beast::iless > sinks_
void write(beast::severities::Severity level, std::string const &partition, std::string const &text, bool console)
beast::Journal::Sink & get(std::string const &name)
static void format(std::string &output, std::string const &message, beast::severities::Severity severity, std::string const &partition)
bool open(boost::filesystem::path const &pathToLogFile)