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

provides information about where and when a log message was generated. More...

#include <log_message.hpp>

Public Member Functions

 log_context ()
 
 log_context (log_level ll, const char *file, uint64_t line, const char *method)
 
 ~log_context ()
 
 log_context (const variant &v)
 
variant to_variant () const
 
string get_file () const
 
uint64_t get_line_number () const
 
string get_method () const
 
string get_thread_name () const
 
string get_task_name () const
 
string get_host_name () const
 
time_point get_timestamp () const
 
log_level get_log_level () const
 
string get_context () const
 
void append_context (const fc::string &c)
 
string to_string () const
 

Detailed Description

See also
FC_LOG_CONTEXT

Definition at line 55 of file log_message.hpp.

Constructor & Destructor Documentation

◆ log_context() [1/3]

fc::log_context::log_context ( )

Definition at line 42 of file log_message.cpp.

43 :my( std::make_shared<detail::log_context_impl>() ){}

◆ log_context() [2/3]

fc::log_context::log_context ( log_level ll,
const char * file,
uint64_t line,
const char * method )

Definition at line 45 of file log_message.cpp.

47 :my( std::make_shared<detail::log_context_impl>() )
48 {
49 my->level = ll;
50 my->file = fc::path(file).filename().generic_string(); // TODO truncate filename
51 my->line = line;
52 my->method = method;
53 my->timestamp = time_point::now();
54 my->thread_name = fc::get_thread_name();
55 }
wraps boost::filesystem::path to provide platform independent path manipulation.
fc::path filename() const
std::string generic_string() const
static time_point now()
Definition time.cpp:14
const string & get_thread_name()
Here is the call graph for this function:

◆ ~log_context()

fc::log_context::~log_context ( )

Definition at line 87 of file log_message.cpp.

87{}

◆ log_context() [3/3]

fc::log_context::log_context ( const variant & v)
explicit

Definition at line 57 of file log_message.cpp.

58 :my( std::make_shared<detail::log_context_impl>() )
59 {
60 auto obj = v.get_object();
61 my->level = obj["level"].as<log_level>();
62 my->file = obj["file"].as_string();
63 my->line = obj["line"].as_uint64();
64 my->method = obj["method"].as_string();
65 my->hostname = obj["hostname"].as_string();
66 my->thread_name = obj["thread_name"].as_string();
67 if (obj.contains("task_name"))
68 my->task_name = obj["task_name"].as_string();
69 my->timestamp = obj["timestamp"].as<time_point>();
70 if( obj.contains( "context" ) )
71 my->context = obj["context"].as<string>();
72 }
Here is the call graph for this function:

Member Function Documentation

◆ append_context()

void fc::log_context::append_context ( const fc::string & c)

Definition at line 80 of file log_message.cpp.

81 {
82 if (!my->context.empty())
83 my->context += " -> ";
84 my->context += s;
85 }
char * s
Here is the caller graph for this function:

◆ get_context()

string fc::log_context::get_context ( ) const

Definition at line 176 of file log_message.cpp.

176{ return my->context; }

◆ get_file()

string fc::log_context::get_file ( ) const

Definition at line 168 of file log_message.cpp.

168{ return my->file; }

◆ get_host_name()

string fc::log_context::get_host_name ( ) const

Definition at line 173 of file log_message.cpp.

173{ return my->hostname; }

◆ get_line_number()

uint64_t fc::log_context::get_line_number ( ) const

Definition at line 169 of file log_message.cpp.

169{ return my->line; }

◆ get_log_level()

log_level fc::log_context::get_log_level ( ) const

Definition at line 175 of file log_message.cpp.

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

◆ get_method()

string fc::log_context::get_method ( ) const

Definition at line 170 of file log_message.cpp.

170{ return my->method; }

◆ get_task_name()

string fc::log_context::get_task_name ( ) const

Definition at line 172 of file log_message.cpp.

172{ return my->task_name; }

◆ get_thread_name()

string fc::log_context::get_thread_name ( ) const

Definition at line 171 of file log_message.cpp.

171{ return my->thread_name; }

◆ get_timestamp()

time_point fc::log_context::get_timestamp ( ) const

Definition at line 174 of file log_message.cpp.

174{ return my->timestamp; }

◆ to_string()

fc::string fc::log_context::to_string ( ) const

Definition at line 74 of file log_message.cpp.

75 {
76 return my->thread_name + " " + my->file + ":" + fc::to_string(my->line) + " " + my->method;
77
78 }
fc::string to_string(double)
Definition string.cpp:131
Here is the call graph for this function:

◆ to_variant()

variant fc::log_context::to_variant ( ) const

Definition at line 179 of file log_message.cpp.

180 {
181 mutable_variant_object o;
182 o( "level", variant(my->level) )
183 ( "file", my->file )
184 ( "line", my->line )
185 ( "method", my->method )
186 ( "hostname", my->hostname )
187 ( "thread_name", my->thread_name )
188 ( "timestamp", variant(my->timestamp) );
189
190 if( my->context.size() )
191 o( "context", my->context );
192
193 return o;
194 }

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