Electroneum
Loading...
Searching...
No Matches
misc_log_ex.h File Reference
#include <string>
#include "easylogging++.h"
#include <assert.h>
Include dependency graph for misc_log_ex.h:

Go to the source code of this file.

Namespaces

namespace  epee
namespace  epee::debug

Macros

#define ELECTRONEUM_DEFAULT_LOG_CATEGORY   "default"
#define MAX_LOG_FILE_SIZE   104850000
#define MAX_LOG_FILES   50
#define MCLOG_TYPE(level, cat, type, x)
#define MCLOG(level, cat, x)
#define MCLOG_FILE(level, cat, x)
#define MCFATAL(cat, x)
#define MCERROR(cat, x)
#define MCWARNING(cat, x)
#define MCINFO(cat, x)
#define MCDEBUG(cat, x)
#define MCTRACE(cat, x)
#define MCLOG_COLOR(level, cat, color, x)
#define MCLOG_RED(level, cat, x)
#define MCLOG_GREEN(level, cat, x)
#define MCLOG_YELLOW(level, cat, x)
#define MCLOG_BLUE(level, cat, x)
#define MCLOG_MAGENTA(level, cat, x)
#define MCLOG_CYAN(level, cat, x)
#define MLOG_RED(level, x)
#define MLOG_GREEN(level, x)
#define MLOG_YELLOW(level, x)
#define MLOG_BLUE(level, x)
#define MLOG_MAGENTA(level, x)
#define MLOG_CYAN(level, x)
#define MFATAL(x)
#define MERROR(x)
#define MWARNING(x)
#define MINFO(x)
#define MDEBUG(x)
#define MTRACE(x)
#define MLOG(level, x)
#define MGINFO(x)
#define MGINFO_RED(x)
#define MGINFO_GREEN(x)
#define MGINFO_YELLOW(x)
#define MGINFO_BLUE(x)
#define MGINFO_MAGENTA(x)
#define MGINFO_CYAN(x)
#define IFLOG(level, cat, type, init, x)
#define MIDEBUG(init, x)
#define LOG_ERROR(x)
#define LOG_PRINT_L0(x)
#define LOG_PRINT_L1(x)
#define LOG_PRINT_L2(x)
#define LOG_PRINT_L3(x)
#define LOG_PRINT_L4(x)
#define _dbg3(x)
#define _dbg2(x)
#define _dbg1(x)
#define _info(x)
#define _note(x)
#define _fact(x)
#define _mark(x)
#define _warn(x)
#define _erro(x)
#define MLOG_SET_THREAD_NAME(x)
#define LOCAL_ASSERT(expr)
#define ENDL   std::endl
#define TRY_ENTRY()
#define CATCH_ENTRY(location, return_val)
#define CATCH_ENTRY_L0(lacation, return_val)
#define CATCH_ENTRY_L1(lacation, return_val)
#define CATCH_ENTRY_L2(lacation, return_val)
#define CATCH_ENTRY_L3(lacation, return_val)
#define CATCH_ENTRY_L4(lacation, return_val)
#define ASSERT_MES_AND_THROW(message)
#define CHECK_AND_ASSERT_THROW_MES(expr, message)
#define CHECK_AND_ASSERT(expr, fail_ret_val)
#define CHECK_AND_ASSERT_MES(expr, fail_ret_val, message)
#define CHECK_AND_NO_ASSERT_MES_L(expr, fail_ret_val, l, message)
#define CHECK_AND_NO_ASSERT_MES(expr, fail_ret_val, message)
#define CHECK_AND_NO_ASSERT_MES_L1(expr, fail_ret_val, message)
#define CHECK_AND_ASSERT_MES_NO_RET(expr, message)
#define CHECK_AND_ASSERT_MES2(expr, message)

Enumerations

enum  epee::console_colors {
  epee::console_color_default , epee::console_color_white , epee::console_color_red , epee::console_color_green ,
  epee::console_color_blue , epee::console_color_cyan , epee::console_color_magenta , epee::console_color_yellow
}

Functions

std::string mlog_get_default_log_path (const char *default_filename)
void mlog_configure (const std::string &filename_base, bool console, const std::size_t max_log_file_size=MAX_LOG_FILE_SIZE, const std::size_t max_log_files=MAX_LOG_FILES)
void mlog_set_categories (const char *categories)
std::string mlog_get_categories ()
void mlog_set_log_level (int level)
void mlog_set_log (const char *log)
bool epee::debug::get_set_enable_assert (bool set=false, bool v=false)
bool epee::is_stdout_a_tty ()
void epee::set_console_color (int color, bool bright)
void epee::reset_console_color ()

Macro Definition Documentation

◆ _dbg1

#define _dbg1 ( x)
Value:
#define MDEBUG(x)
Definition misc_log_ex.h:76

Definition at line 107 of file misc_log_ex.h.

◆ _dbg2

#define _dbg2 ( x)
Value:

Definition at line 106 of file misc_log_ex.h.

◆ _dbg3

#define _dbg3 ( x)
Value:
#define MTRACE(x)
Definition misc_log_ex.h:77

Definition at line 105 of file misc_log_ex.h.

◆ _erro

#define _erro ( x)
Value:
#define MERROR(x)
Definition misc_log_ex.h:73

Definition at line 113 of file misc_log_ex.h.

◆ _fact

#define _fact ( x)
Value:

Definition at line 110 of file misc_log_ex.h.

◆ _info

#define _info ( x)
Value:
#define MINFO(x)
Definition misc_log_ex.h:75

Definition at line 108 of file misc_log_ex.h.

◆ _mark

#define _mark ( x)
Value:

Definition at line 111 of file misc_log_ex.h.

◆ _note

#define _note ( x)
Value:

Definition at line 109 of file misc_log_ex.h.

◆ _warn

#define _warn ( x)
Value:
#define MWARNING(x)
Definition misc_log_ex.h:74

Definition at line 112 of file misc_log_ex.h.

◆ ASSERT_MES_AND_THROW

#define ASSERT_MES_AND_THROW ( message)
Value:
{LOG_ERROR(message); std::stringstream ss; ss << message; throw std::runtime_error(ss.str());}
std::string message("Message requiring signing")
#define LOG_ERROR(x)
Definition misc_log_ex.h:98

Definition at line 172 of file misc_log_ex.h.

◆ CATCH_ENTRY

#define CATCH_ENTRY ( location,
return_val )
Value:
} \
catch(const std::exception& ex) \
{ \
(void)(ex); \
LOG_ERROR("Exception at [" << location << "], what=" << ex.what()); \
return return_val; \
}\
catch(...)\
{\
LOG_ERROR("Exception at [" << location << "], generic exception \"...\"");\
return return_val; \
}

Definition at line 152 of file misc_log_ex.h.

152#define CATCH_ENTRY(location, return_val) } \
153 catch(const std::exception& ex) \
154{ \
155 (void)(ex); \
156 LOG_ERROR("Exception at [" << location << "], what=" << ex.what()); \
157 return return_val; \
158}\
159 catch(...)\
160{\
161 LOG_ERROR("Exception at [" << location << "], generic exception \"...\"");\
162 return return_val; \
163}

◆ CATCH_ENTRY_L0

#define CATCH_ENTRY_L0 ( lacation,
return_val )
Value:
CATCH_ENTRY(lacation, return_val)
#define CATCH_ENTRY(location, return_val)

Definition at line 165 of file misc_log_ex.h.

◆ CATCH_ENTRY_L1

#define CATCH_ENTRY_L1 ( lacation,
return_val )
Value:
CATCH_ENTRY(lacation, return_val)

Definition at line 166 of file misc_log_ex.h.

◆ CATCH_ENTRY_L2

#define CATCH_ENTRY_L2 ( lacation,
return_val )
Value:
CATCH_ENTRY(lacation, return_val)

Definition at line 167 of file misc_log_ex.h.

◆ CATCH_ENTRY_L3

#define CATCH_ENTRY_L3 ( lacation,
return_val )
Value:
CATCH_ENTRY(lacation, return_val)

Definition at line 168 of file misc_log_ex.h.

◆ CATCH_ENTRY_L4

#define CATCH_ENTRY_L4 ( lacation,
return_val )
Value:
CATCH_ENTRY(lacation, return_val)

Definition at line 169 of file misc_log_ex.h.

◆ CHECK_AND_ASSERT

#define CHECK_AND_ASSERT ( expr,
fail_ret_val )
Value:
do{if(!(expr)){LOCAL_ASSERT(expr); return fail_ret_val;};}while(0)
#define LOCAL_ASSERT(expr)

Definition at line 177 of file misc_log_ex.h.

◆ CHECK_AND_ASSERT_MES

#define CHECK_AND_ASSERT_MES ( expr,
fail_ret_val,
message )
Value:
do{if(!(expr)) {LOG_ERROR(message); return fail_ret_val;};}while(0)

Definition at line 181 of file misc_log_ex.h.

◆ CHECK_AND_ASSERT_MES2

#define CHECK_AND_ASSERT_MES2 ( expr,
message )
Value:
do{if(!(expr)) {LOG_ERROR(message); };}while(0)

Definition at line 203 of file misc_log_ex.h.

◆ CHECK_AND_ASSERT_MES_NO_RET

#define CHECK_AND_ASSERT_MES_NO_RET ( expr,
message )
Value:
do{if(!(expr)) {LOG_ERROR(message); return;};}while(0)

Definition at line 198 of file misc_log_ex.h.

◆ CHECK_AND_ASSERT_THROW_MES

#define CHECK_AND_ASSERT_THROW_MES ( expr,
message )
Value:
do {if(!(expr)) ASSERT_MES_AND_THROW(message);} while(0)
#define ASSERT_MES_AND_THROW(message)

Definition at line 173 of file misc_log_ex.h.

◆ CHECK_AND_NO_ASSERT_MES

#define CHECK_AND_NO_ASSERT_MES ( expr,
fail_ret_val,
message )
Value:
CHECK_AND_NO_ASSERT_MES_L(expr, fail_ret_val, 0, message)
#define CHECK_AND_NO_ASSERT_MES_L(expr, fail_ret_val, l, message)

Definition at line 189 of file misc_log_ex.h.

◆ CHECK_AND_NO_ASSERT_MES_L

#define CHECK_AND_NO_ASSERT_MES_L ( expr,
fail_ret_val,
l,
message )
Value:
do{if(!(expr)) {LOG_PRINT_L##l(message); /*LOCAL_ASSERT(expr);*/ return fail_ret_val;};}while(0)

Definition at line 185 of file misc_log_ex.h.

◆ CHECK_AND_NO_ASSERT_MES_L1

#define CHECK_AND_NO_ASSERT_MES_L1 ( expr,
fail_ret_val,
message )
Value:
CHECK_AND_NO_ASSERT_MES_L(expr, fail_ret_val, 1, message)

Definition at line 193 of file misc_log_ex.h.

◆ ELECTRONEUM_DEFAULT_LOG_CATEGORY

#define ELECTRONEUM_DEFAULT_LOG_CATEGORY   "default"

Definition at line 36 of file misc_log_ex.h.

◆ ENDL

#define ENDL   std::endl

Definition at line 149 of file misc_log_ex.h.

◆ IFLOG

#define IFLOG ( level,
cat,
type,
init,
x )
Value:
do { \
if (ELPP->vRegistry()->allowed(level, cat)) { \
init; \
el::base::Writer(level, __FILE__, __LINE__, ELPP_FUNC, type).construct(cat) << x; \
} \
} while(0)
#define ELPP_FUNC
#define ELPP

Definition at line 88 of file misc_log_ex.h.

88#define IFLOG(level, cat, type, init, x) \
89 do { \
90 if (ELPP->vRegistry()->allowed(level, cat)) { \
91 init; \
92 el::base::Writer(level, __FILE__, __LINE__, ELPP_FUNC, type).construct(cat) << x; \
93 } \
94 } while(0)

◆ LOCAL_ASSERT

#define LOCAL_ASSERT ( expr)

Definition at line 122 of file misc_log_ex.h.

◆ LOG_ERROR

#define LOG_ERROR ( x)
Value:

Definition at line 98 of file misc_log_ex.h.

◆ LOG_PRINT_L0

#define LOG_PRINT_L0 ( x)
Value:

Definition at line 99 of file misc_log_ex.h.

◆ LOG_PRINT_L1

#define LOG_PRINT_L1 ( x)
Value:

Definition at line 100 of file misc_log_ex.h.

◆ LOG_PRINT_L2

#define LOG_PRINT_L2 ( x)
Value:

Definition at line 101 of file misc_log_ex.h.

◆ LOG_PRINT_L3

#define LOG_PRINT_L3 ( x)
Value:

Definition at line 102 of file misc_log_ex.h.

◆ LOG_PRINT_L4

#define LOG_PRINT_L4 ( x)
Value:

Definition at line 103 of file misc_log_ex.h.

◆ MAX_LOG_FILE_SIZE

#define MAX_LOG_FILE_SIZE   104850000

Definition at line 38 of file misc_log_ex.h.

◆ MAX_LOG_FILES

#define MAX_LOG_FILES   50

Definition at line 39 of file misc_log_ex.h.

◆ MCDEBUG

#define MCDEBUG ( cat,
x )
Value:
#define MCLOG(level, cat, x)
Definition misc_log_ex.h:47
@ Debug
Informational events most useful for developers to debug application.

Definition at line 54 of file misc_log_ex.h.

◆ MCERROR

#define MCERROR ( cat,
x )
Value:
@ Error
Information representing errors in application but application will keep running.

Definition at line 51 of file misc_log_ex.h.

◆ MCFATAL

#define MCFATAL ( cat,
x )
Value:
@ Fatal
Severe error information that will presumably abort application.

Definition at line 50 of file misc_log_ex.h.

◆ MCINFO

#define MCINFO ( cat,
x )
Value:
@ Info
Mainly useful to represent current progress of application.

Definition at line 53 of file misc_log_ex.h.

◆ MCLOG

#define MCLOG ( level,
cat,
x )
Value:
#define MCLOG_TYPE(level, cat, type, x)
Definition misc_log_ex.h:41

Definition at line 47 of file misc_log_ex.h.

◆ MCLOG_BLUE

#define MCLOG_BLUE ( level,
cat,
x )
Value:
MCLOG_COLOR(level,cat,"34",x)
#define MCLOG_COLOR(level, cat, color, x)
Definition misc_log_ex.h:57

Definition at line 61 of file misc_log_ex.h.

◆ MCLOG_COLOR

#define MCLOG_COLOR ( level,
cat,
color,
x )
Value:
MCLOG(level,cat,"\033[1;" color "m" << x << "\033[0m")

Definition at line 57 of file misc_log_ex.h.

◆ MCLOG_CYAN

#define MCLOG_CYAN ( level,
cat,
x )
Value:
MCLOG_COLOR(level,cat,"36",x)

Definition at line 63 of file misc_log_ex.h.

◆ MCLOG_FILE

#define MCLOG_FILE ( level,
cat,
x )
Value:

Definition at line 48 of file misc_log_ex.h.

◆ MCLOG_GREEN

#define MCLOG_GREEN ( level,
cat,
x )
Value:
MCLOG_COLOR(level,cat,"32",x)

Definition at line 59 of file misc_log_ex.h.

◆ MCLOG_MAGENTA

#define MCLOG_MAGENTA ( level,
cat,
x )
Value:
MCLOG_COLOR(level,cat,"35",x)

Definition at line 62 of file misc_log_ex.h.

◆ MCLOG_RED

#define MCLOG_RED ( level,
cat,
x )
Value:
MCLOG_COLOR(level,cat,"31",x)

Definition at line 58 of file misc_log_ex.h.

◆ MCLOG_TYPE

#define MCLOG_TYPE ( level,
cat,
type,
x )
Value:
do { \
if (ELPP->vRegistry()->allowed(level, cat)) { \
el::base::Writer(level, __FILE__, __LINE__, ELPP_FUNC, type).construct(cat) << x; \
} \
} while (0)

Definition at line 41 of file misc_log_ex.h.

41#define MCLOG_TYPE(level, cat, type, x) do { \
42 if (ELPP->vRegistry()->allowed(level, cat)) { \
43 el::base::Writer(level, __FILE__, __LINE__, ELPP_FUNC, type).construct(cat) << x; \
44 } \
45 } while (0)

◆ MCLOG_YELLOW

#define MCLOG_YELLOW ( level,
cat,
x )
Value:
MCLOG_COLOR(level,cat,"33",x)

Definition at line 60 of file misc_log_ex.h.

◆ MCTRACE

#define MCTRACE ( cat,
x )
Value:
@ Trace
Information that can be useful to back-trace certain events - mostly useful than debug logs.

Definition at line 55 of file misc_log_ex.h.

◆ MCWARNING

#define MCWARNING ( cat,
x )
Value:
@ Warning
Useful when application has potentially harmful situtaions.

Definition at line 52 of file misc_log_ex.h.

◆ MDEBUG

#define MDEBUG ( x)
Value:
#define ELECTRONEUM_DEFAULT_LOG_CATEGORY
Definition misc_log_ex.h:36
#define MCDEBUG(cat, x)
Definition misc_log_ex.h:54

Definition at line 76 of file misc_log_ex.h.

◆ MERROR

#define MERROR ( x)
Value:

Definition at line 73 of file misc_log_ex.h.

◆ MFATAL

#define MFATAL ( x)
Value:

Definition at line 72 of file misc_log_ex.h.

◆ MGINFO

#define MGINFO ( x)
Value:
MCINFO("global",x)
#define MCINFO(cat, x)
Definition misc_log_ex.h:53

Definition at line 80 of file misc_log_ex.h.

◆ MGINFO_BLUE

#define MGINFO_BLUE ( x)
Value:
#define MCLOG_BLUE(level, cat, x)
Definition misc_log_ex.h:61

Definition at line 84 of file misc_log_ex.h.

◆ MGINFO_CYAN

#define MGINFO_CYAN ( x)
Value:
#define MCLOG_CYAN(level, cat, x)
Definition misc_log_ex.h:63

Definition at line 86 of file misc_log_ex.h.

◆ MGINFO_GREEN

#define MGINFO_GREEN ( x)
Value:
#define MCLOG_GREEN(level, cat, x)
Definition misc_log_ex.h:59

Definition at line 82 of file misc_log_ex.h.

◆ MGINFO_MAGENTA

#define MGINFO_MAGENTA ( x)
Value:
#define MCLOG_MAGENTA(level, cat, x)
Definition misc_log_ex.h:62

Definition at line 85 of file misc_log_ex.h.

◆ MGINFO_RED

#define MGINFO_RED ( x)
Value:
#define MCLOG_RED(level, cat, x)
Definition misc_log_ex.h:58

Definition at line 81 of file misc_log_ex.h.

◆ MGINFO_YELLOW

#define MGINFO_YELLOW ( x)
Value:
#define MCLOG_YELLOW(level, cat, x)
Definition misc_log_ex.h:60

Definition at line 83 of file misc_log_ex.h.

◆ MIDEBUG

#define MIDEBUG ( init,
x )
Value:

Definition at line 95 of file misc_log_ex.h.

◆ MINFO

#define MINFO ( x)
Value:

Definition at line 75 of file misc_log_ex.h.

◆ MLOG

#define MLOG ( level,
x )
Value:

Definition at line 78 of file misc_log_ex.h.

◆ MLOG_BLUE

#define MLOG_BLUE ( level,
x )
Value:

Definition at line 68 of file misc_log_ex.h.

◆ MLOG_CYAN

#define MLOG_CYAN ( level,
x )
Value:

Definition at line 70 of file misc_log_ex.h.

◆ MLOG_GREEN

#define MLOG_GREEN ( level,
x )
Value:

Definition at line 66 of file misc_log_ex.h.

◆ MLOG_MAGENTA

#define MLOG_MAGENTA ( level,
x )
Value:

Definition at line 69 of file misc_log_ex.h.

◆ MLOG_RED

#define MLOG_RED ( level,
x )
Value:

Definition at line 65 of file misc_log_ex.h.

◆ MLOG_SET_THREAD_NAME

#define MLOG_SET_THREAD_NAME ( x)
Value:
static void setThreadName(const std::string &name)
Sets thread name for current thread. Requires std::thread.

Definition at line 115 of file misc_log_ex.h.

◆ MLOG_YELLOW

#define MLOG_YELLOW ( level,
x )
Value:

Definition at line 67 of file misc_log_ex.h.

◆ MTRACE

#define MTRACE ( x)
Value:

Definition at line 77 of file misc_log_ex.h.

◆ MWARNING

#define MWARNING ( x)
Value:

Definition at line 74 of file misc_log_ex.h.

◆ TRY_ENTRY

#define TRY_ENTRY ( )
Value:
try {

Definition at line 151 of file misc_log_ex.h.

Function Documentation

◆ mlog_configure()

void mlog_configure ( const std::string & filename_base,
bool console,
const std::size_t max_log_file_size = MAX_LOG_FILE_SIZE,
const std::size_t max_log_files = MAX_LOG_FILES )

Definition at line 148 of file mlog.cpp.

149{
153 const char *log_format = getenv("ELECTRONEUM_LOG_FORMAT");
154 if (!log_format)
155 log_format = MLOG_BASE_FORMAT;
157 c.setGlobally(el::ConfigurationType::ToStandardOutput, console ? "true" : "false");
158 c.setGlobally(el::ConfigurationType::MaxLogFileSize, std::to_string(max_log_file_size));
160
166 el::Helpers::installPreRollOutCallback([filename_base, max_log_files](const char *name, size_t){
167 std::string rname = generate_log_filename(filename_base.c_str());
168 int ret = rename(name, rname.c_str());
169 if (ret < 0)
170 {
171 // can't log a failure, but don't do the file removal below
172 return;
173 }
174 if (max_log_files != 0)
175 {
176 std::vector<boost::filesystem::path> found_files;
177 const boost::filesystem::directory_iterator end_itr;
178 const boost::filesystem::path filename_base_path(filename_base);
179 const boost::filesystem::path parent_path = filename_base_path.has_parent_path() ? filename_base_path.parent_path() : ".";
180 for (boost::filesystem::directory_iterator iter(parent_path); iter != end_itr; ++iter)
181 {
182 const std::string filename = iter->path().string();
183 if (filename.size() >= filename_base.size() && std::memcmp(filename.data(), filename_base.data(), filename_base.size()) == 0)
184 {
185 found_files.push_back(iter->path());
186 }
187 }
188 if (found_files.size() >= max_log_files)
189 {
190 std::sort(found_files.begin(), found_files.end(), [](const boost::filesystem::path &a, const boost::filesystem::path &b) {
191 boost::system::error_code ec;
192 std::time_t ta = boost::filesystem::last_write_time(boost::filesystem::path(a), ec);
193 if (ec)
194 {
195 MERROR("Failed to get timestamp from " << a << ": " << ec);
196 ta = std::time(nullptr);
197 }
198 std::time_t tb = boost::filesystem::last_write_time(boost::filesystem::path(b), ec);
199 if (ec)
200 {
201 MERROR("Failed to get timestamp from " << b << ": " << ec);
202 tb = std::time(nullptr);
203 }
204 static_assert(std::is_integral<time_t>(), "bad time_t");
205 return ta < tb;
206 });
207 for (size_t i = 0; i <= found_files.size() - max_log_files; ++i)
208 {
209 try
210 {
211 boost::system::error_code ec;
212 boost::filesystem::remove(found_files[i], ec);
213 if (ec)
214 {
215 MERROR("Failed to remove " << found_files[i] << ": " << ec);
216 }
217 }
218 catch (const std::exception &e)
219 {
220 MERROR("Failed to remove " << found_files[i] << ": " << e.what());
221 }
222 }
223 }
224 }
225 });
226 mlog_set_common_prefix();
227 const char *electroneum_log = getenv("ELECTRONEUM_LOGS");
228 if (!electroneum_log)
229 {
230 electroneum_log = get_default_categories(0);
231 }
232 mlog_set_log(electroneum_log);
233#ifdef WIN32
234 EnableVTMode();
235#endif
236}
else if(0==res)
Thread-safe Configuration repository.
void setGlobally(ConfigurationType configurationType, const std::string &value)
Sets configuration for all levels.
static void installPreRollOutCallback(const PreRollOutCallback &callback)
Installs pre rollout callback, this callback is triggered when log file is about to be rolled out (ca...
static void setDefaultConfigurations(const Configurations &configurations, bool reconfigureExistingLoggers=false)
Sets default configurations. This configuration is used for future (and conditionally for existing) l...
static void addFlag(LoggingFlag flag)
Adds logging flag used internally.
void mlog_set_log(const char *log)
Definition mlog.cpp:288
#define MLOG_BASE_FORMAT
Definition mlog.cpp:49
@ CreateLoggerAutomatically
Creates logger automatically when not available.
@ HierarchicalLogging
Enables hierarchical logging.
@ StrictLogFileSizeCheck
Enables strict file rolling.
@ DisableApplicationAbortOnFatalLog
Allows to disable application abortion when logged using FATAL level.
@ ColoredTerminalOutput
Make terminal output colorful for supported terminals.
@ Filename
Determines log file (full path) to write logs to for correponding level and logger.
@ MaxLogFileSize
Specifies log file max size.
@ Format
Determines format of logging corresponding level and logger.
@ ToStandardOutput
Whether or not to write corresponding level and logger log to standard output. By standard output mea...
@ ToFile
Whether or not to write corresponding log to log file.
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition pointer.h:1124
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mlog_get_categories()

std::string mlog_get_categories ( )

Definition at line 276 of file mlog.cpp.

277{
279}
static std::string getCategories()
Gets current categories.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mlog_get_default_log_path()

std::string mlog_get_default_log_path ( const char * default_filename)

Definition at line 72 of file mlog.cpp.

73{
74 std::string process_name = epee::string_tools::get_current_module_name();
75 std::string default_log_folder = epee::string_tools::get_current_module_folder();
76 std::string default_log_file = process_name;
77 std::string::size_type a = default_log_file.rfind('.');
78 if ( a != std::string::npos )
79 default_log_file.erase( a, default_log_file.size());
80 if ( ! default_log_file.empty() )
81 default_log_file += ".log";
82 else
83 default_log_file = default_filename;
84
85 return (boost::filesystem::path(default_log_folder) / boost::filesystem::path(default_log_file)).string();
86}
std::string & get_current_module_name()
std::string & get_current_module_folder()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mlog_set_categories()

void mlog_set_categories ( const char * categories)

Definition at line 238 of file mlog.cpp.

239{
240 std::string new_categories;
241 if (*categories)
242 {
243 if (*categories == '+')
244 {
245 ++categories;
246 new_categories = mlog_get_categories();
247 if (*categories)
248 {
249 if (!new_categories.empty())
250 new_categories += ",";
251 new_categories += categories;
252 }
253 }
254 else if (*categories == '-')
255 {
256 ++categories;
257 new_categories = mlog_get_categories();
258 std::vector<std::string> single_categories;
259 boost::split(single_categories, categories, boost::is_any_of(","), boost::token_compress_on);
260 for (const std::string &s: single_categories)
261 {
262 size_t pos = new_categories.find(s);
263 if (pos != std::string::npos)
264 new_categories = new_categories.erase(pos, s.size());
265 }
266 }
267 else
268 {
269 new_categories = categories;
270 }
271 }
272 el::Loggers::setCategories(new_categories.c_str(), true);
273 MLOG_LOG("New log categories: " << el::Loggers::getCategories());
274}
static void setCategories(const char *categories, bool clear=true)
Sets categories as specified (on the fly).
std::string mlog_get_categories()
Definition mlog.cpp:276
#define MLOG_LOG(x)
Definition mlog.cpp:51
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mlog_set_log()

void mlog_set_log ( const char * log)

Definition at line 288 of file mlog.cpp.

289{
290 long level;
291 char *ptr = NULL;
292
293 if (!*log)
294 {
296 return;
297 }
298 level = strtol(log, &ptr, 10);
299 if (ptr && *ptr)
300 {
301 // we can have a default level, eg, 2,foo:ERROR
302 if (*ptr == ',') {
303 std::string new_categories = std::string(get_default_categories(level)) + ptr;
304 mlog_set_categories(new_categories.c_str());
305 }
306 else {
308 }
309 }
310 else if (level >= 0 && level <= 4)
311 {
312 mlog_set_log_level(level);
313 }
314 else
315 {
316 MERROR("Invalid numerical log level: " << log);
317 }
318}
void mlog_set_log_level(int level)
Definition mlog.cpp:282
void mlog_set_categories(const char *categories)
Definition mlog.cpp:238
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mlog_set_log_level()

void mlog_set_log_level ( int level)

Definition at line 282 of file mlog.cpp.

283{
284 const char *categories = get_default_categories(level);
285 mlog_set_categories(categories);
286}
Here is the call graph for this function:
Here is the caller graph for this function: