From d9c4a95345bd758e45196b29368bd2ff0f2790e3 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 6 Apr 2013 13:14:48 +0200 Subject: tagging ychat-0.5.2 --- logd.cpp | 65 ++++++++++++++++++++++++++++++++-------------------------------- 1 file changed, 33 insertions(+), 32 deletions(-) (limited to 'logd.cpp') diff --git a/logd.cpp b/logd.cpp index cfdc7c6..63c2a64 100644 --- a/logd.cpp +++ b/logd.cpp @@ -5,57 +5,58 @@ logd::logd( string filename ) { - if(filename.empty()) - { - cerr << "ycLog: No filename specified" << endl; - exit(1); - } - - s_logfile=filename; + if(filename.empty()) + { + cerr << "ycLog: No filename specified" << endl; + exit(1); + } - i_lines=s_tool::string2int( s_conf::get().get_val("LOG_LINES")); + s_logfile=filename; + + i_lines=s_tool::string2int( s_conf::get + ().get_val("LOG_LINES")); } void logd::flush() { - s_output.open(s_logfile.c_str(), ios::app); + s_output.open(s_logfile.c_str(), ios::app); - if(s_output==NULL) - { - cerr << "ycLog: Could not open file: " << s_logfile << endl; - exit(1); - } + if(s_output==NULL) + { + cerr << "ycLog: Could not open file: " << s_logfile << endl; + exit(1); + } - while(!s_queue.empty()) - { - string s_l=s_queue.front(); - s_queue.pop(); - s_output.write(s_l.c_str(), s_l.size()); + while(!s_queue.empty()) + { + string s_l=s_queue.front(); + s_queue.pop(); + s_output.write(s_l.c_str(), s_l.size()); - } - s_output.close(); + } + s_output.close(); } void logd::log( map_string request ) { - struct tm *t_m; - time_t t_cur=time(NULL); - t_m=gmtime(&t_cur); + struct tm *t_m; + time_t t_cur=time(NULL); + t_m=gmtime(&t_cur); - char buffer[100]; - strftime(buffer, 100, "[%d/%b/%Y:%H:%M:%S %z]", t_m); - string s_time=buffer; - string s_logstr = request["REMOTE_ADDR"] + " - - "+s_time+" \"" + request["QUERY_STRING"]+"\" 200 0 \""+request["request"]+"\" \""+request["User-Agent"]+"\"\n"; + char buffer[100]; + strftime(buffer, 100, "[%d/%b/%Y:%H:%M:%S %z]", t_m); + string s_time=buffer; + string s_logstr = request["REMOTE_ADDR"] + " - - "+s_time+" \"" + request["QUERY_STRING"]+"\" 200 0 \""+request["request"]+"\" \""+request["User-Agent"]+"\"\n"; - s_queue.push(s_logstr); + s_queue.push(s_logstr); - if(s_queue.size()>=i_lines) - flush(); + if(s_queue.size()>=i_lines) + flush(); } logd::~logd() { - flush(); + flush(); } -- cgit v1.2.3