29 using namespace shogun;
35 "[NOTICE] \0",
"[WARN] \0",
"[ERROR] \0",
36 "[CRITICAL] \0",
"[ALERT] \0",
"[EMERGENCY] \0",
"\0"};
39 "[NOTICE] \0",
"\033[1;34m[WARN]\033[0m \0",
"\033[1;31m[ERROR]\033[0m \0",
40 "[CRITICAL] \0",
"[ALERT] \0",
"[EMERGENCY] \0",
"\0"};
49 : target(stdout), last_progress_time(0), progress_start_time(0),
50 last_progress(1), show_progress(false), location_info(
MSG_NONE),
51 syntax_highlight(true), loglevel(
MSG_WARN)
57 : target(orig.get_target()), last_progress_time(0),
58 progress_start_time(0), last_progress(1),
59 show_progress(orig.get_show_progress()),
60 location_info(orig.get_location_info()),
61 syntax_highlight(orig.get_syntax_highlight()),
62 loglevel(orig.get_loglevel())
68 int32_t line,
const char *fmt, ... )
const
75 snprintf(str,
sizeof(str),
"%s", msg_intro);
76 int len=strlen(msg_intro);
82 snprintf(s,
sizeof(str)-len,
"In file %s line %d: ", file, line);
88 snprintf(s,
sizeof(str)-len,
"%s: ",
function);
99 vsnprintf(s,
sizeof(str)-len, fmt, list);
140 fprintf(
target,
"%s", msg_intro);
143 vfprintf(
target,fmt,list);
150 int32_t decimals,
const char* prefix)
158 float64_t v=-1, estimate=0, total_estimate=0 ;
160 if (max_val-min_val>0.0)
161 v=100*(current_val-min_val+1)/(max_val-min_val+1);
187 snprintf(str,
sizeof(str),
"%%s %%%d.%df%%%% %%1.1f minutes remaining %%1.1f minutes total \r",decimals+3, decimals);
192 snprintf(str,
sizeof(str),
"%%s %%%d.%df%%%% %%1.1f seconds remaining %%1.1f seconds total \r",decimals+3, decimals);
201 int32_t decimals,
const char* prefix)
209 float64_t v=-1, estimate=0, total_estimate=0 ;
211 if (max_val-min_val>0)
212 v=100*(val-min_val+1)/(max_val-min_val+1);
238 snprintf(str,
sizeof(str),
"%%s %%%d.%df %%1.1f minutes remaining %%1.1f minutes total \r",decimals+3, decimals);
243 snprintf(str,
sizeof(str),
"%%s %%%d.%df %%1.1f seconds remaining %%1.1f seconds total \r",decimals+3, decimals);
264 for (i=0; isspace(str[i]); i++);
278 for (i=0; isblank(str[i]); i++);
325 char* ret = SG_CALLOC(
char, len);
326 memcpy(ret,s.
start,len-1);
339 char* endptr = s.
end;
349 char* endptr = s.
end;
360 int32_t int_val = atoi(c_string);
368 return strtoul(s.
start,NULL,10);
391 if (!access(fname, R_OK))
394 if (!stat(fname, &s) && S_ISREG(s.st_mode))
409 return m_refcount->
ref();
419 int32_t rc = m_refcount->
unref();
void set_loglevel(EMessageType level)
static char * skip_spaces(char *str)
int32_t ref_count() const
static uint32_t ss_length(substring s)
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
static char * skip_blanks(char *str)
static int filter(CONST_DIRENT_T *d)
struct Substring, specified by start position and end position.
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
void message(EMessageType prio, const char *function, const char *file, int32_t line, const char *fmt,...) const
static char * c_string_of_substring(substring s)
float64_t last_progress_time
static float32_t float_of_substring(substring s)
static uint32_t ulong_of_substring(substring s)
static const char * message_strings[NUM_LOG_LEVELS]
static void print_substring(substring s)
EMessageType get_loglevel() const
float64_t progress_start_time
void(* sg_print_message)(FILE *target, const char *str)
function called to print normal messages
static int32_t int_of_substring(substring s)
EMessageLocation location_info
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")
static char * concat_filename(const char *filename)
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 float64_t double_of_substring(substring s)
static const EMessageType levels[NUM_LOG_LEVELS]
static const char * message_strings_highlighted[NUM_LOG_LEVELS]