CodeAddress: https://github.com/hanxi/Log
/* ========================================================== =========================================== # Filename: log. h # Desc: log record, only support single thread, support webpage format # Author: hanxi # Email: hanxi.com@gmail.com # homepage: Http://hanxi.cnblogs.com # Version: 0.0.1 # lastchange: 2013-03-07 18:24:21 # History: ========================================================== ============================================ */ # Ifndef _ log_h _ # Define _ Log_h _ // STD # Include <iostream> # Include <Fstream> # Include < String > # Include <Ctime> # Include <Cstdlib> # Define Html_log 1 // Output in HTML Format # Define Txt_log 2 // Output in TXT format Class Log { Private : Static STD: ofstream ms_file; // Log File stream Static Const Char * Ms_path; // Log File Path Static Int Ms_loglevel; // Logs smaller than loglevel will be printed Static Int Ms_logfiletype; // Log File Type Int M_nowlevel; STD :: String * M_thefunctionname; // Enter the function name Public : Static Void S_init ( Const Char * I _path, Int I _loglevel, Int I _filetype ); Static Void S_stop (); Static Const Char * Endl; log ( Const Char * Funcname, Int Loglevel ); ~ Log (); Template <Typename type> Void Debug (type MSG); Template <Typename type> Log & Operator < (Type MSG );}; // Initialize static member variables STD: ofstream log: ms_file; Const Char * Log: ms_path = NULL; // Log File Path Int Log: ms_loglevel = 0 ; // Logs smaller than loglevel will be printed Int Log: ms_logfiletype = 0 ; // Log File Type Const Char * Log: Endl = " \ N " ;
/* ========================================================== =========================================== # Filename: trace. h # Desc: Debugging class # Author: hanxi # Email: hanxi.com@gmail.com # homepage: Http://hanxi.cnblogs.com # Version: 0.0.1 # lastchange: 2013-03-08 13:05:03 # History: ========================================================== ============================================ */ # Ifndef _ trace_h _ # Define _ Trace_h _ # Include <Iostream> Using Namespace STD; Class Trace { Public : Trace ( Const Char * Name ); ~ Trace (); Void Debug ( Const String & MSG ); Static Bool Traceisactive; Private : String * Thefunctionname ;}; Bool Trace: traceisactive = False ;