27 using namespace shogun;
33 "[NOTICE] \0",
"[WARN] \0",
"[ERROR] \0",
34 "[CRITICAL] \0",
"[ALERT] \0",
"[EMERGENCY] \0",
"\0"};
37 "[NOTICE] \0",
"\033[1;34m[WARN]\033[0m \0",
"\033[1;31m[ERROR]\033[0m \0",
38 "[CRITICAL] \0",
"[ALERT] \0",
"[EMERGENCY] \0",
"\0"};
47 : target(stdout), last_progress_time(0), progress_start_time(0),
48 last_progress(1), show_progress(false), show_file_and_line(false),
49 syntax_highlight(true), loglevel(
MSG_WARN), refcount(0)
54 : target(orig.get_target()), last_progress_time(0),
55 progress_start_time(0), last_progress(1),
56 show_progress(orig.get_show_progress()),
57 show_file_and_line(orig.get_show_file_and_line()),
58 syntax_highlight(orig.get_syntax_highlight()),
59 loglevel(orig.get_loglevel()), refcount(0)
64 int32_t line,
const char *fmt, ... )
const
71 snprintf(str,
sizeof(str),
"%s", msg_intro);
72 int len=strlen(msg_intro);
77 snprintf(s,
sizeof(str)-len,
"In file %s line %d: ", file, line);
84 vsnprintf(s,
sizeof(str)-len, fmt, list);
125 fprintf(
target,
"%s", msg_intro);
128 vfprintf(
target,fmt,list);
135 int32_t decimals,
const char* prefix)
143 float64_t v=-1, estimate=0, total_estimate=0 ;
145 if (max_val-min_val>0.0)
146 v=100*(current_val-min_val+1)/(max_val-min_val+1);
172 snprintf(str,
sizeof(str),
"%%s %%%d.%df%%%% %%1.1f minutes remaining %%1.1f minutes total \r",decimals+3, decimals);
177 snprintf(str,
sizeof(str),
"%%s %%%d.%df%%%% %%1.1f seconds remaining %%1.1f seconds total \r",decimals+3, decimals);
186 int32_t decimals,
const char* prefix)
194 float64_t v=-1, estimate=0, total_estimate=0 ;
196 if (max_val-min_val>0)
197 v=100*(val-min_val+1)/(max_val-min_val+1);
223 snprintf(str,
sizeof(str),
"%%s %%%d.%df %%1.1f minutes remaining %%1.1f minutes total \r",decimals+3, decimals);
228 snprintf(str,
sizeof(str),
"%%s %%%d.%df %%1.1f seconds remaining %%1.1f seconds total \r",decimals+3, decimals);
249 for (i=0; isspace(str[i]); i++);
263 for (i=0; isblank(str[i]); i++);
void set_loglevel(EMessageType level)
static char * skip_spaces(char *str)
void buffered_message(EMessageType prio, const char *fmt,...) const
void set_target(FILE *target)
Class ShogunException defines an exception which is thrown whenever an error inside of shogun occurs...
void(* sg_print_warning)(FILE *target, const char *str)
function called to print warning messages
void message(EMessageType prio, const char *file, int32_t line, const char *fmt,...) const
static char * skip_blanks(char *str)
static float64_t get_curtime()
static char file_buffer[FBUFSIZE]
file name buffer
void(* sg_print_error)(FILE *target, const char *str)
function called to print error messages
float64_t last_progress_time
static const char * message_strings[NUM_LOG_LEVELS]
EMessageType get_loglevel() const
float64_t progress_start_time
void(* sg_print_message)(FILE *target, const char *str)
function called to print normal messages
const char * get_msg_intro(EMessageType prio) const
static char directory_name[FBUFSIZE]
directory name buffer
void progress(float64_t current_val, float64_t min_val=0.0, float64_t max_val=1.0, int32_t decimals=1, const char *prefix="PROGRESS:\t")
void absolute_progress(float64_t current_val, float64_t val, float64_t min_val=0.0, float64_t max_val=1.0, int32_t decimals=1, const char *prefix="PROGRESS:\t")
Class SGIO, used to do input output operations throughout shogun.
static T clamp(T value, T lb, T ub)
return the value clamped to interval [lb,ub]
static const EMessageType levels[NUM_LOG_LEVELS]
static const char * message_strings_highlighted[NUM_LOG_LEVELS]