Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
fc::log_message Class Reference

aggregates a message along with the context and associated meta-information. More...

#include <log_message.hpp>

Public Member Functions

 log_message ()
 
 log_message (log_context ctx, std::string format, variant_object args=variant_object())
 
 ~log_message ()
 
 log_message (const variant &v)
 
variant to_variant () const
 
string get_message () const
 
string get_limited_message () const
 
log_context get_context () const
 
string get_format () const
 
variant_object get_data () const
 

Detailed Description

Note
log_message has reference semantics, all copies refer to the same log message and the message is read-only after construction.

When converted to JSON, log_message has the following form:

{
"context" : { ... },
"format" : "string with ${keys}",
"data" : { "keys" : "values" }
}
See also
FC_LOG_MESSAGE

Definition at line 105 of file log_message.hpp.

Constructor & Destructor Documentation

◆ log_message() [1/3]

fc::log_message::log_message ( )

Definition at line 197 of file log_message.cpp.

198 :my( std::make_shared<detail::log_message_impl>() ){}

◆ log_message() [2/3]

fc::log_message::log_message ( log_context ctx,
std::string format,
variant_object args = variant_object() )
Parameters
ctx- generally provided using the FC_LOG_CONTEXT(LEVEL) macro

Definition at line 200 of file log_message.cpp.

201 :my( std::make_shared<detail::log_message_impl>(std::move(ctx)) )
202 {
203 my->format = std::move(format);
204 my->args = std::move(args);
205 }
cmd_format format

◆ ~log_message()

fc::log_message::~log_message ( )

Definition at line 196 of file log_message.cpp.

196{}

◆ log_message() [3/3]

fc::log_message::log_message ( const variant & v)

Definition at line 207 of file log_message.cpp.

208 :my( std::make_shared<detail::log_message_impl>( log_context( v.get_object()["context"] ) ) )
209 {
210 my->format = v.get_object()["format"].as_string();
211 my->args = v.get_object()["data"].get_object();
212 }
Here is the call graph for this function:

Member Function Documentation

◆ get_context()

log_context fc::log_message::get_context ( ) const

Definition at line 221 of file log_message.cpp.

221{ return my->context; }
Here is the caller graph for this function:

◆ get_data()

variant_object fc::log_message::get_data ( ) const

Definition at line 223 of file log_message.cpp.

223{ return my->args; }
Here is the caller graph for this function:

◆ get_format()

string fc::log_message::get_format ( ) const

Definition at line 222 of file log_message.cpp.

222{ return my->format; }
Here is the caller graph for this function:

◆ get_limited_message()

string fc::log_message::get_limited_message ( ) const

A faster version of get_message which does limited formatting and excludes large variants

Returns
formatted message according to format and variant args

Definition at line 230 of file log_message.cpp.

231 {
232 const bool minimize = true;
233 return format_string( my->format, my->args, minimize );
234 }
fc::string format_string(const fc::string &, const variant_object &, bool minimize=false)
Definition variant.cpp:773
Here is the call graph for this function:

◆ get_message()

string fc::log_message::get_message ( ) const

Definition at line 225 of file log_message.cpp.

226 {
227 return format_string( my->format, my->args );
228 }
Here is the call graph for this function:

◆ to_variant()

variant fc::log_message::to_variant ( ) const

Definition at line 214 of file log_message.cpp.

215 {
216 return mutable_variant_object( "context", my->context )
217 ( "format", my->format )
218 ( "data", my->args );
219 }
Here is the caller graph for this function:

The documentation for this class was generated from the following files: