Virtual U.org
Get Personal Training on VU Today
    
Top shadow
 
 register/help
User Name:

Password:

OLOG.CPP Source File
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

OLOG.CPP

Go to the documentation of this file.
00001 // Filename    : OLOG.CPP
00002 // Description : logging class
00003 // Owner       : Gilbert
00004 
00005 #include <OLOG.H>
00006 #include <STDIO.H>
00007 #include <OFILE.H>
00008 
00009 // -------- begin of function Log::Log ----------//
00010 Log::Log() {
00011 }
00012 
00013 // -------- end of function Log::Log ----------//
00014 
00015 Log::~Log() {
00016 }
00017 
00018 // -------- begin of function Log::mark_begin ----------//
00019 void Log::mark_begin() {
00020     // text_buffer[0] stores the latest log
00021     text_buffer[0].clear();
00022     *(text_buffer[0].reserve(sizeof(char))) = '\0'; // put a null character in the buffer
00023 }
00024 
00025 // -------- end of function Log::mark_begin ----------//
00026 
00027 // -------- begin of function Log::mark_end ----------//
00028 void Log::mark_end() {
00029     // enable next line to trace hang
00030     // dump();
00031 
00032     // rotate buffers
00033     text_buffer[LOG_VERSION-1].clear();
00034     // put a null character in the buffer
00035     *(text_buffer[LOG_VERSION-1].reserve(sizeof(char))) = '\0';
00036     for(int n = LOG_VERSION-1; n > 0; --n) {
00037         text_buffer[n].swap(text_buffer[n-1]);
00038     }
00039 }
00040 
00041 // -------- end of function Log::mark_end ----------//
00042 
00043 // -------- begin of function Log::mark ----------//
00044 void Log::mark(char *msg, char *file, int line) {
00045     log_text = msg;
00046     log_file = file;
00047     log_line = line;
00048 
00049     String t(log_text);
00050     t += "\r\n";
00051     strcpy( text_buffer[0].reserve(t.len())-1, t ); // minus 1 to remove the '\0' at the end
00052 }
00053 
00054 // -------- end of function Log::mark ----------//
00055 
00056 // -------- begin of function Log::mark ----------//
00057 void Log::mark(int n , char *file, int line) {
00058     log_text = n;
00059     log_file = file;
00060     log_line = line;
00061 
00062     String t(log_text);
00063     t += "\r\n";
00064     strcpy( text_buffer[0].reserve(t.len())-1, t );
00065 }
00066 
00067 // -------- end of function Log::mark ----------//
00068 
00069 // -------- begin of function Log::dump ----------//
00070 void Log::dump() {
00071     // write old_buffer
00072     char filename[20];
00073     strcpy(filename, "AM_A.LOG");
00074     File f;
00075     // AM_A.LOG, AM_B.LOG ...
00076     for(int n = LOG_VERSION-1; n >= 0; --n, filename[3]++) {
00077         f.file_create(filename);
00078         f.file_write( text_buffer[n].queue_buf, text_buffer[n].length() );
00079         f.file_close();
00080     }
00081 }
00082 
00083 // -------- end of function Log::dump ----------//
00084 
00085 // -------- begin of function Log::debug_log ----------//
00086 void Log::debug_log(char *msg) {
00087     String s;
00088     s = msg;
00089     s += "\r\n";
00090     OutputDebugString(s);
00091 }
00092 
00093 void Log::debug_log(int n) {
00094     String s;
00095     s = n;
00096     s += "\r\n";
00097     OutputDebugString(s);
00098 }
00099 
00100 // -------- end of function Log::debug_log ----------//

Generated on Fri Aug 23 01:38:03 2002 for VirtualU by doxygen1.2.17