-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdebug.cpp
61 lines (51 loc) · 1.48 KB
/
debug.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include "debug.h"
#include <time.h>
extern int present_clock;
debug::debug():err(NULL){
char *str = filename;
time_t run;
time(&run);
struct tm *tp = localtime(&run);
sprintf( str,"%02ld-%02ld-%04ld.log",tp->tm_mon+1,tp->tm_mday,tp->tm_year+1900 );
err = fopen( str,"w" );
fprintf( err,"Green Signal Log File.\n\n" );
fputs("----------------------------------------\n",err);
fprintf( err,"The Date: " );
fprintf( err,"\t%s\n",ctime(&run) );
warn_times = 0;
}
debug::debug(char *name){
char *str = filename;
sprintf( str,"%s.log",name );
err = fopen( str,"w" );
fputs("Green Signal Log File.\n",err);
fputs("----------------------------------------\n",err);
fprintf( err,"Input File: \t%s\n",name );
time_t run;
time(&run);
localtime(&run);
fprintf( err,"The Date: " );
fprintf( err,"\t%s\n",ctime(&run) );
warn_times = 0;
}
debug::~debug(){
//fprintf( err,"Green Signal Version 1.00.\n" );
sprintf(tmpstr,"Total %d warnings.\n",warn_times);
fputs(tmpstr,err);
fputs("Green Signal Version 0.1 beta\n",err);
fclose(err);
}
char *debug::get_str(){ return tmpstr; }
void debug::process(char *str){
//fputs("[Process]",err);
//fprintf( err," @%04d> %s\n\n",present_clock,str );
}
void debug::warning( char *str){
fputs("[Warning]",err);
fprintf( err," @%04d> %s\n\n",present_clock,str );
warn_times++;
}
void debug::throws( char *str ){
fputs("[Error]",err);
fprintf( err," @%04d> %s\n\n",present_clock,str );
}