28 using namespace shogun;
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();