34 "[NOTICE] \0",
"[WARN] \0",
"[ERROR] \0",
35 "[CRITICAL] \0",
"[ALERT] \0",
"[EMERGENCY] \0",
"\0"};
38 "[NOTICE] \0",
"\033[1;34m[WARN]\033[0m \0",
"\033[1;31m[ERROR]\033[0m \0",
39 "[CRITICAL] \0",
"[ALERT] \0",
"[EMERGENCY] \0",
"\0"};
48 : target(stdout), last_progress_time(0), progress_start_time(0),
49 last_progress(1), show_progress(false), location_info(
MSG_NONE),
50 syntax_highlight(true), loglevel(
MSG_WARN)
56 : target(orig.get_target()), last_progress_time(0),
57 progress_start_time(0), last_progress(1),
58 show_progress(orig.get_show_progress()),
59 location_info(orig.get_location_info()),
60 syntax_highlight(orig.get_syntax_highlight()),
61 loglevel(orig.get_loglevel())
67 int32_t line,
const char *fmt, ... )
const
74 snprintf(str,
sizeof(str),
"%s", msg_intro);
75 int len=strlen(msg_intro);
81 snprintf(s,
sizeof(str)-len,
"In file %s line %d: ", file, line);
87 snprintf(s,
sizeof(str)-len,
"%s: ",
function);
98 vsnprintf(s,
sizeof(str)-len, fmt, list);
139 fprintf(
target,
"%s", msg_intro);
142 vfprintf(
target,fmt,list);
149 int32_t decimals,
const char* prefix)
157 float64_t v=-1, estimate=0, total_estimate=0 ;
159 if (max_val-min_val>0.0)
160 v=100*(current_val-min_val+1)/(max_val-min_val+1);
186 snprintf(str,
sizeof(str),
"%%s %%%d.%df%%%% %%1.1f minutes remaining %%1.1f minutes total \r",decimals+3, decimals);
191 snprintf(str,
sizeof(str),
"%%s %%%d.%df%%%% %%1.1f seconds remaining %%1.1f seconds total \r",decimals+3, decimals);
200 int32_t decimals,
const char* prefix)
208 float64_t v=-1, estimate=0, total_estimate=0 ;
210 if (max_val-min_val>0)
211 v=100*(val-min_val+1)/(max_val-min_val+1);
237 snprintf(str,
sizeof(str),
"%%s %%%d.%df %%1.1f minutes remaining %%1.1f minutes total \r",decimals+3, decimals);
242 snprintf(str,
sizeof(str),
"%%s %%%d.%df %%1.1f seconds remaining %%1.1f seconds total \r",decimals+3, decimals);
263 for (i=0; isspace(str[i]); i++);
277 for (i=0; isblank(str[i]); i++);
324 char* ret = SG_CALLOC(
char, len);
325 memcpy(ret,s.
start,len-1);
338 char* endptr = s.
end;
348 char* endptr = s.
end;
359 int32_t int_val = atoi(c_string);
367 return strtoul(s.
start,NULL,10);
390 if (!access(fname, R_OK))
393 if (!stat(fname, &s) && S_ISREG(s.st_mode))
408 return m_refcount->
ref();
418 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
all of classes and functions are contained in the shogun namespace
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)
static float64_t double_of_substring(substring s)
static const EMessageType levels[NUM_LOG_LEVELS]
static const char * message_strings_highlighted[NUM_LOG_LEVELS]