55 c[0] = getenv(
"WINDIR")[0];
88void Log::loc(
LogLevel level,
const string & filename,
int linenum,
const string & func)
106 const char *key =
"";
124 fprintf(file,
"%s", key);
125 vfprintf(file, format, arg);
127 fprintf(file,
" at %s",
location.c_str());
135 va_start(arg, format);
143 va_start(arg, format);
151 va_start(arg, format);
159 va_start(arg, format);
172 if (filename && !
out) {
173 out = fopen(filename,
"wb");
180 const char *pwd = getenv(
"PWD");
187 sprintf(s,
"%d\t%d\t%d\t%d\t%s", ref, (
int)tm, 0, ppid ? ppid : getppid(), filename.c_str());
189 sprintf(s,
"%d\t%d\t%d\t%d\t%s", ref, (
int)tm, 0, ppid, filename.c_str());
191 for (
int i = 1; i < argc; i++) {
192 sprintf(s + strlen(s),
" %s", argv[i]);
194 sprintf(s + strlen(s),
"\n");
202 fprintf(eman_file,
"%s", s);
206 FILE *in = fopen(dirlist.c_str(),
"r");
210 while (fscanf(in,
" %1023s", s) == 1) {
211 if (strcmp(s, pwd) == 0) {
224 FILE *dirout = fopen(dirlist.c_str(),
"a");
226 fprintf(dirout,
"%s\n", pwd);
235void Log::end(
int ref,
const string& file,
const string& text)
237 FILE *
out = fopen(
".emanlog",
"a");
242 fprintf(
out,
"%d\t%ld\t%s\t%s\n", ref, tm, file.c_str(), text.c_str());
Log defines a way to output logging information.
void end(int ref, const string &file="-", const string &text="")
void debug(const char *format,...)
log a debug message.
void vlog(const char *format, LogLevel level, va_list arg)
void set_level(int level)
void loc(LogLevel level, const string &file, int linenum, const string &func)
int begin(int argc, char *argv[], int ppid)
begin() and start() are used by command-line programs
void error(const char *format,...)
log an error message.
void warn(const char *format,...)
log a warning message.
void set_logfile(const char *filename)
set log output file.
void variable(const char *format,...)
log a very-detailed-level debug message.
static string sbasename(const string &filename)
Get a filename's basename.
static string int2str(int n)
Get a string format of an integer, e.g.