42 "[NOTICE] \0",
"[WARN] \0",
"[ERROR] \0",
43 "[CRITICAL] \0",
"[ALERT] \0",
"[EMERGENCY] \0",
"\0"};
46 "[NOTICE] \0",
"\033[1;34m[WARN]\033[0m \0",
"\033[1;31m[ERROR]\033[0m \0",
47 "[CRITICAL] \0",
"[ALERT] \0",
"[EMERGENCY] \0",
"\0"};
56 : target(stdout), last_progress_time(0), progress_start_time(0),
57 last_progress(0), show_progress(false), location_info(
MSG_NONE),
58 syntax_highlight(true), loglevel(
MSG_WARN)
75 int32_t line,
const char *fmt, ... )
const 82 snprintf(str,
sizeof(str),
"%s", msg_intro);
83 int len=strlen(msg_intro);
89 snprintf(s,
sizeof(str)-len,
"In file %s line %d: ", file, line);
95 snprintf(s,
sizeof(str)-len,
"%s: ",
function);
106 vsnprintf(s,
sizeof(str)-len, fmt, list);
147 fprintf(
target,
"%s", msg_intro);
150 vfprintf(
target,fmt,list);
157 int32_t decimals,
const char* prefix)
165 float64_t v=-1, estimate=0, total_estimate=0 ;
167 if (max_val-min_val>0.0)
168 v=100*(current_val-min_val+1)/(max_val-min_val+1);
191 if (current_val >= max_val-1)
195 snprintf(str,
sizeof(str),
"%%s %%%d.%df%%%% %%1.1f seconds remaining %%1.1f seconds total ",decimals+3, decimals);
209 snprintf(str,
sizeof(str),
"%%s %%%d.%df%%%% %%1.1f minutes remaining %%1.1f minutes total \r",decimals+3, decimals);
214 snprintf(str,
sizeof(str),
"%%s %%%d.%df%%%% %%1.1f seconds remaining %%1.1f seconds total \r",decimals+3, decimals);
220 if (current_val >= max_val-1)
230 int32_t decimals,
const char* prefix)
238 float64_t v=-1, estimate=0, total_estimate=0 ;
240 if (max_val-min_val>0)
241 v=100*(val-min_val+1)/(max_val-min_val+1);
267 snprintf(str,
sizeof(str),
"%%s %%%d.%df %%1.1f minutes remaining %%1.1f minutes total \r",decimals+3, decimals);
272 snprintf(str,
sizeof(str),
"%%s %%%d.%df %%1.1f seconds remaining %%1.1f seconds total \r",decimals+3, decimals);
293 for (i=0; isspace(str[i]); i++);
307 for (i=0; isblank(str[i]); i++);
354 char* ret = SG_CALLOC(
char, len);
355 sg_memcpy(ret,s.
start,len-1);
368 char* endptr = s.
end;
378 char* endptr = s.
end;
389 int32_t int_val = atoi(c_string);
397 return strtoul(s.
start,NULL,10);
424 if (!access(fname, R_OK))
427 if (!stat(fname, &s) && S_ISREG(s.st_mode))
442 return m_refcount->
ref();
452 int32_t rc = m_refcount->
unref();
void set_loglevel(EMessageType level)
static char * skip_spaces(char *str)
const char * get_msg_intro(EMessageType prio) const
static uint32_t ss_length(substring s)
bool get_show_progress() 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
int32_t ref_count() const
SG_FORCED_INLINE int32_t ref()
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
EMessageType get_loglevel() const
void(* sg_print_error)(FILE *target, const char *str)
function called to print error messages
bool get_syntax_highlight() const
SG_FORCED_INLINE int32_t unref()
static char * c_string_of_substring(substring s)
float64_t last_progress_time
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:\)
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)
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
all of classes and functions are contained in the shogun namespace
void message(EMessageType prio, const char *function, const char *file, int32_t line, const char *fmt,...) const
static char directory_name[FBUFSIZE]
directory name buffer
EMessageLocation get_location_info() const
SG_FORCED_INLINE int32_t ref_count()
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)
static float64_t double_of_substring(substring s)
static const EMessageType levels[NUM_LOG_LEVELS]
FILE * get_target() const
static const char * message_strings_highlighted[NUM_LOG_LEVELS]
void buffered_message(EMessageType prio, const char *fmt,...) const
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:\)