log.h File Reference


Detailed Description

Handles log files.

Definition in file log.h.

#include <string>

Include dependency graph for log.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define TYPE_CTCP   130
 Type: CTCP (only for irc_check_flood()).
#define TYPE_IRCOP_JOIN   131
 Type: TYPE_IRCOP_JOIN.
#define TYPE_IRCOP_LEFT   132
 Type: TYPE_IRCOP_LEFT.
#define TYPE_JOIN   3
 Type: JOIN.
#define TYPE_KICK   6
 Type: KICK.
#define TYPE_MODE   7
 Type: MODE.
#define TYPE_NICK   8
 Type: NICK.
#define TYPE_NOTICE   2
 Type: NOTICE.
#define TYPE_PART   4
 Type: PART.
#define TYPE_PRIVMSG   1
 Type: PRIVMSG.
#define TYPE_QUIT   5
 Type: QUIT.
#define TYPE_QUIT_PART_KICK   128
 Type: QUIT/PART/been KICK-ed (only for irc_check_flood()).
#define TYPE_REPEAT   129
 Type: repeat (only for irc_check_flood()).
#define TYPE_SCRIPT   9
 Type: Message from script.
#define TYPE_TOPIC   10
 Type TOPIC (not for flood!).

Functions

void log_bot (const char *msg)
 Writes debug string to file logs/bot.log and to stdout if log_echo_bot == true.
void log_botnet (const char *myname, const char *remote_name, const char *msg)
 Writes error message of origin botnet.
void log_botnet_debug (const char *myname, const char *remote_name, int packet_type, int command, const char *msg)
 Writes error message of origin botnet (botnet debug messages).
void log_broadcast (string bcast_mask, int type, string who, string msg, string server, unsigned short server_port)
 Writes string to file logs/broadcast.log and to stdout if log_echo_broadcast == true.
void log_debug (const char *msg)
 Writes debug string to file logs/debug.log and to stdout if log_echo_debug == true.
string log_done (int exit_code, string eol)
 Shuts down the log files.
void log_free_locks ()
 Frees the lock files.
void log_identd (const char *msg)
 Writes debug string to file logs/identd.log and to stdout if log_echo_identd == true.
bool log_init ()
 Inits the log files.
void log_irc (bool from_server, const char *msg)
 Writes debug string to file logs/irc.log and to stdout if log_echo_irc == true.
void log_socket (int sock_error, const char *os_msg, const char *msg)
 Writes debug string to file logs/socket.log and to stdout if log_echo_socket == true.
void log_ssl (const char *msg)
 Writes debug string to file logs/ssl.log and to stdout if log_echo_ssl == true.


Define Documentation

#define TYPE_CTCP   130
 

Type: CTCP (only for irc_check_flood()).

Definition at line 118 of file log.h.

Referenced by irc_check_flood(), irc_loop_process_input(), and logic_on_flood().

#define TYPE_IRCOP_JOIN   131
 

Type: TYPE_IRCOP_JOIN.

Definition at line 123 of file log.h.

Referenced by irc_loop_process_input(), irc_RPL_WHOISOPERATOR(), and log_channel().

#define TYPE_IRCOP_LEFT   132
 

Type: TYPE_IRCOP_LEFT.

Definition at line 128 of file log.h.

Referenced by irc_loop_process_input(), and log_channel().

#define TYPE_JOIN   3
 

Type: JOIN.

Definition at line 68 of file log.h.

Referenced by irc_check_flood(), irc_loop_process_input(), log_channel(), and logic_on_flood().

#define TYPE_KICK   6
 

Type: KICK.

Definition at line 83 of file log.h.

Referenced by irc_loop_process_input(), log_channel(), and logic_on_part().

#define TYPE_MODE   7
 

Type: MODE.

Definition at line 88 of file log.h.

Referenced by irc_check_flood(), irc_loop_process_input(), log_channel(), and logic_on_flood().

#define TYPE_NICK   8
 

Type: NICK.

Definition at line 93 of file log.h.

Referenced by irc_check_flood(), irc_loop_process_input(), log_channel(), and logic_on_flood().

#define TYPE_NOTICE   2
 

Type: NOTICE.

Definition at line 63 of file log.h.

Referenced by irc_check_flood(), irc_loop_process_input(), log_broadcast(), log_channel(), logic_on_broadcast(), logic_on_flood(), and logic_on_server_msg().

#define TYPE_PART   4
 

Type: PART.

Definition at line 73 of file log.h.

Referenced by irc_loop_process_input(), log_channel(), and logic_on_part().

#define TYPE_PRIVMSG   1
 

Type: PRIVMSG.

Definition at line 58 of file log.h.

Referenced by irc_check_flood(), irc_loop_process_input(), log_broadcast(), log_channel(), logic_on_broadcast(), logic_on_flood(), and logic_on_server_msg().

#define TYPE_QUIT   5
 

Type: QUIT.

Definition at line 78 of file log.h.

Referenced by irc_loop_process_input(), log_channel(), and logic_on_part().

#define TYPE_QUIT_PART_KICK   128
 

Type: QUIT/PART/been KICK-ed (only for irc_check_flood()).

Definition at line 108 of file log.h.

Referenced by irc_check_flood(), and irc_loop_process_input().

#define TYPE_REPEAT   129
 

Type: repeat (only for irc_check_flood()).

Definition at line 113 of file log.h.

Referenced by irc_check_flood(), and logic_on_flood().

#define TYPE_SCRIPT   9
 

Type: Message from script.

Definition at line 98 of file log.h.

Referenced by log_channel(), and logic_process_script_output().

#define TYPE_TOPIC   10
 

Type TOPIC (not for flood!).

Definition at line 103 of file log.h.

Referenced by irc_loop_process_input(), and log_channel().


Function Documentation

void log_bot const char *  msg  ) 
 

Writes debug string to file logs/bot.log and to stdout if log_echo_bot == true.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
msg The log message

Definition at line 253 of file log.cpp.

References FILE_SLASH, init_echoes(), log_bot_, log_echo_bot, log_initialized, logic_on_internal_event(), and PRIVATE_EVENT_SEVERITY_CODE_INFORMATIONAL.

Referenced by dcc_loop(), dcc_upgrade(), irc_loop_process_input(), irc_quoted_callback(), log_done(), log_init(), logic_botnet_rehash(), logic_exec(), logic_partyline_backup(), logic_partyline_rehash(), logic_rehash(), logic_rollback(), main(), and write_kill_log().

00254 {
00255     if(!log_initialized)
00256         init_echoes();
00257 
00258     if(log_bot_) {
00259         FILE* f=fopen("logs" FILE_SLASH "bot.log","a");
00260         if(f) {
00261             char now[128];
00262             time_t n=time(NULL);
00263             strcpy(now,ctime(&n));
00264             now[26-1-1]=0;
00265             fprintf(f,"%s%s%s\n",now,": ",msg);
00266             fclose(f);
00267         }
00268     }
00269 
00270     if(log_echo_bot)
00271         printf("%s%s\n","BOT     ",msg);
00272 
00273     logic_on_internal_event("@log@","bot","","","",PRIVATE_EVENT_SEVERITY_CODE_INFORMATIONAL,msg,"");
00274 }

Here is the call graph for this function:

void log_botnet const char *  myname,
const char *  remote_name,
const char *  msg
 

Writes error message of origin botnet.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
myname Name of this bot
remote_name Name of remote bot
msg The log message

Definition at line 494 of file log.cpp.

References FILE_SLASH, init_echoes(), log_botnet_, log_echo_botnet, log_initialized, logic_on_internal_event(), and PRIVATE_EVENT_SEVERITY_CODE_INFORMATIONAL.

Referenced by botnet_loop(), botnet_push_chan(), botnet_push_proc(), botnet_push_prv(), botnet_push_user(), botnet_receive(), and log_init().

00495 {
00496     if(!log_initialized)
00497         init_echoes();
00498 
00499     if(log_botnet_) {
00500         FILE* f=fopen("logs" FILE_SLASH "botnet.log","a");
00501         if(f) {
00502             char now[128];
00503             time_t n=time(NULL);
00504             strcpy(now,ctime(&n));
00505             now[26-1-1]=0;
00506             fprintf(f,"%s * %s->%s %s\n",now,myname,remote_name,msg);
00507             fclose(f);
00508         }
00509     }
00510 
00511     if(log_echo_botnet)
00512         printf("BOTNET  %s->%s %s\n",myname,remote_name,msg);
00513 
00514     logic_on_internal_event("@log@","botnet",remote_name,"","",PRIVATE_EVENT_SEVERITY_CODE_INFORMATIONAL,msg,"");
00515 }

Here is the call graph for this function:

void log_botnet_debug const char *  myname,
const char *  remote_name,
int  packet_type,
int  command,
const char *  msg
 

Writes error message of origin botnet (botnet debug messages).

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
myname Name of this bot
remote_name Name of remote bot
packet_type Type of packet
command Command number
msg The log message

Definition at line 458 of file log.cpp.

References FILE_SLASH, init_echoes(), log_botnet_debug_, log_echo_botnet_debug, log_initialized, logic_on_internal_event(), and PRIVATE_EVENT_SEVERITY_CODE_INFORMATIONAL.

Referenced by botnet_loop(), botnet_push_chan(), botnet_push_proc(), botnet_push_prv(), botnet_push_user(), botnet_send_command(), botnet_send_control(), and log_init().

00459 {
00460     if(!log_initialized)
00461         init_echoes();
00462 
00463     if(log_botnet_debug_) {
00464         FILE* f=fopen("logs" FILE_SLASH "botnet_debug.log","a");
00465         if(f) {
00466             char now[128];
00467             time_t n=time(NULL);
00468             strcpy(now,ctime(&n));
00469             now[26-1-1]=0;
00470             fprintf(f,"%s * MyName=%s RemoteName=%s PacketType=%d Command=%d * %s\n",now,myname,remote_name,packet_type,command,msg);
00471             fclose(f);
00472         }
00473     }
00474 
00475     if(log_echo_botnet_debug)
00476         printf("BOTNET  MyName=%s RemoteName=%s PacketType=%d Command=%d * %s\n",myname,remote_name,packet_type,command,msg);
00477 
00478     char* final_msg=new char[strlen(myname)+strlen(remote_name)+strlen(msg)+10*1024];
00479     sprintf(final_msg,"BOTNET  MyName=%s RemoteName=%s PacketType=%d Command=%d * %s",myname,remote_name,packet_type,command,msg);
00480     logic_on_internal_event("@log@","botnet_debug",remote_name,"","",PRIVATE_EVENT_SEVERITY_CODE_INFORMATIONAL,final_msg,"");
00481     delete[] final_msg;
00482     final_msg=NULL;
00483 }

Here is the call graph for this function:

void log_broadcast string  bcast_mask,
int  type,
string  who,
string  msg,
string  server,
unsigned short  server_port
 

Writes string to file logs/broadcast.log and to stdout if log_echo_broadcast == true.

Author:
VooDooMan
Version:
1
Date:
2005-04-22
Parameters:
bcast_mask Broadcast mask used (something like "$$irc.nonexistingdomain.org")
type Type of message: TYPE_PRIVMSG, TYPE_NOTICE; TODO: KILL
who For type == TYPE_PRIVMSG, or TYPE_NOTICE ("nick!ident@host") of originator of message (most likely an irc op)
msg Message
server Server DNS host we are using now
server_port Port of IRC server we are on

Definition at line 750 of file log.cpp.

References FILE_SLASH, init_echoes(), log_initialized, logic_on_internal_event(), PRIVATE_EVENT_SEVERITY_CODE_INFORMATIONAL, TYPE_NOTICE, and TYPE_PRIVMSG.

Referenced by irc_loop_process_input().

00751 {
00752     if(!log_initialized)
00753         init_echoes();
00754 
00755     char* host_str=new char[server.length()+512];
00756     bool _ipv6=server.find(":",0)!=string::npos;
00757     host_str[0]=0;
00758     if(_ipv6)
00759         strcat(host_str,"[");
00760     strcat(host_str,server.c_str());
00761     if(_ipv6)
00762         strcat(host_str,"]");
00763     strcat(host_str,":");
00764     char tmp2[512];
00765     sprintf(tmp2,"%u",(unsigned)server_port);
00766     strcat(host_str,tmp2);
00767 
00768     char tmp[1024];
00769     strcpy(tmp,"logs" FILE_SLASH);
00770     strcat(tmp,"broadcast");
00771     strcat(tmp,".log");
00772 
00773     char* final_msg=new char[who.length()+bcast_mask.length()+strlen(host_str)+msg.length()+10*1024];
00774     final_msg[0]=0;
00775 
00776     FILE* f=fopen(tmp,"a+");
00777     if(f) {
00778         time_t n=time(NULL);
00779         strcpy(tmp,ctime(&n));
00780         tmp[26-1-1]=0;
00781         switch(type) {
00782             case TYPE_PRIVMSG:
00783                 fprintf(f,"%s <%s> PRIVMSG %s (using server %s): %s\n",tmp,who.c_str(),bcast_mask.c_str(),host_str,msg.c_str());
00784                 sprintf(final_msg,"%s <%s> PRIVMSG %s (using server %s): %s",tmp,who.c_str(),bcast_mask.c_str(),host_str,msg.c_str());
00785                 break;
00786             case TYPE_NOTICE:
00787                 fprintf(f,"%s <%s> NOTICE %s (using server %s): %s\n",tmp,who.c_str(),bcast_mask.c_str(),host_str,msg.c_str());
00788                 sprintf(final_msg,"%s <%s> NOTICE %s (using server %s): %s",tmp,who.c_str(),bcast_mask.c_str(),host_str,msg.c_str());
00789                 break;
00790             // TODO: case KILL
00791             default:
00792                 break;
00793         }
00794         fclose(f);
00795     }
00796 
00797     if(final_msg[0])
00798         logic_on_internal_event("@log@","broadcast",who,"","",PRIVATE_EVENT_SEVERITY_CODE_INFORMATIONAL,final_msg,"");
00799 
00800     delete[] final_msg;
00801     final_msg=NULL;
00802 
00803     delete[] host_str;
00804     host_str=NULL;
00805 }

Here is the call graph for this function:

void log_debug const char *  msg  ) 
 

Writes debug string to file logs/debug.log and to stdout if log_echo_debug == true.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
msg The log message

Definition at line 159 of file log.cpp.

References FILE_SLASH, init_echoes(), log_debug_, log_echo_debug, log_initialized, logic_on_internal_event(), and PRIVATE_EVENT_SEVERITY_CODE_INFORMATIONAL.

Referenced by botnet_link(), botnet_receive(), botnet_send_command(), botnet_send_control(), dcc_loop(), dcc_loop_edit_user1(), dcc_loop_edit_user2(), s_bot_command::flip(), handler_sigpipe(), irc_loop_process_input(), irc_loop_putserv(), irc_mode_change_ban(), irc_mode_change_ban_exception(), irc_mode_change_chan_key(), irc_mode_change_chan_limit(), irc_mode_change_chan_status(), irc_mode_change_creator(), irc_mode_change_op(), irc_mode_change_other(), irc_mode_change_voice(), irc_putserv_immediately(), irc_quoted_callback(), irc_RPL_324(), irc_RPL_MODE(), lang_01_init(), lang_get_string(), lang_subst(), log_init(), logic_call_proc_ex(), logic_eval(), logic_exec(), logic_exec_script(), logic_list_proc(), and logic_process_script_output().

00160 {
00161     if(!log_initialized)
00162         init_echoes();
00163 
00164     if(log_debug_) {
00165         FILE* f=fopen("logs" FILE_SLASH "debug.log","a");
00166         if(f) {
00167             char now[128];
00168             time_t n=time(NULL);
00169             strcpy(now,ctime(&n));
00170             now[26-1-1]=0;
00171             fprintf(f,"%s%s%s\n",now,": ",msg);
00172             fclose(f);
00173         }
00174     }
00175 
00176     if(log_echo_debug)
00177         printf("%s%s\n","DEBUG   ",msg);
00178 
00179     logic_on_internal_event("@log@","debug","","","",PRIVATE_EVENT_SEVERITY_CODE_INFORMATIONAL,msg,"");
00180 }

Here is the call graph for this function:

string log_done int  exit_code,
string  eol
 

Shuts down the log files.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
exit_code Exit code for bot used to write it to log
eol EOL string for user who is killing the bot (only if it is a real user, not "root")
Returns:
Returns kill log using EOL as end-of-line marker for user who is killing the bot

Definition at line 694 of file log.cpp.

References dcc_want_to_restart, dcc_want_to_upgrade, log_bot(), log_free_locks(), log_initialized, and stats_display().

Referenced by main().

00695 {
00696     extern bool dcc_want_to_upgrade;
00697     extern bool dcc_want_to_restart;
00698     string res;
00699     if(log_initialized) {
00700         if(!dcc_want_to_upgrade && !dcc_want_to_restart)
00701             log_bot("*** Statistics");
00702         else
00703             log_bot("*** [previous instance] Statistics");
00704 
00705         if(!dcc_want_to_upgrade && !dcc_want_to_restart)
00706             res+="*** Statistics"+eol;
00707         else
00708             res+="*** [previous instance] Statistics"+eol;
00709         list<string> lines;
00710         stats_display(lines,"");
00711         list<string>::iterator i1=lines.begin();
00712         for(; i1!=lines.end(); i1++) {
00713             string ln;
00714             if(!dcc_want_to_upgrade && !dcc_want_to_restart) {
00715                 ln=(string)"*** "+*i1;
00716                 res+=(string)"*** "+*i1+eol;
00717             } else {
00718                 ln=(string)"*** [previous instance] "+*i1;
00719                 res+=(string)"*** [previous instance] "+*i1+eol;
00720             }
00721             log_bot(ln.c_str());
00722         }
00723 
00724         char msg[1024];
00725         if(!dcc_want_to_upgrade && !dcc_want_to_restart)
00726             sprintf(msg,"Exiting normally with exit code %d",exit_code);
00727         else
00728             sprintf(msg,"[previous instance] Exiting normally with exit code %d",exit_code);
00729         log_bot(msg);
00730         res+=(string)msg+eol;
00731     }
00732 
00733     log_free_locks();
00734 
00735     return res;
00736 }

Here is the call graph for this function:

void log_free_locks  ) 
 

Frees the lock files.

Author:
VooDooMan
Version:
1
Date:
2005

Definition at line 668 of file log.cpp.

References FILE_SLASH, pid, and posix_lock_file.

Referenced by dcc_loop(), dcc_upgrade(), and log_done().

00669 {
00670     static bool freed=false;
00671     if(freed)
00672         return;
00673     freed=true;
00674     if(pid)
00675         fclose(pid);
00676     pid=NULL;
00677     if(posix_lock_file!=-1) {
00678         close(posix_lock_file);
00679         unlink("logs" FILE_SLASH "irc_bot.lock");
00680     }
00681     posix_lock_file=-1;
00682     unlink("logs" FILE_SLASH "irc_bot.pid");
00683 }

void log_identd const char *  msg  ) 
 

Writes debug string to file logs/identd.log and to stdout if log_echo_identd == true.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
msg The log message

Definition at line 283 of file log.cpp.

References FILE_SLASH, init_echoes(), log_echo_identd, log_identd_, log_initialized, logic_on_internal_event(), and PRIVATE_EVENT_SEVERITY_CODE_INFORMATIONAL.

Referenced by identd4_shutdown(), identd6_shutdown(), identd_check(), identd_error_log(), identd_shutdown(), and identd_startup().

00284 {
00285     if(!log_initialized)
00286         init_echoes();
00287 
00288     if(log_identd_) {
00289         FILE* f=fopen("logs" FILE_SLASH "identd.log","a");
00290         if(f) {
00291             char now[128];
00292             time_t n=time(NULL);
00293             strcpy(now,ctime(&n));
00294             now[26-1-1]=0;
00295             fprintf(f,"%s%s%s\n",now,": ",msg);
00296             fclose(f);
00297         }
00298     }
00299 
00300     if(log_echo_identd)
00301         printf("%s%s\n","IDENTD  ",msg);
00302 
00303     logic_on_internal_event("@log@","identd","","","",PRIVATE_EVENT_SEVERITY_CODE_INFORMATIONAL,msg,"");
00304 }

Here is the call graph for this function:

bool log_init  ) 
 

Inits the log files.

Author:
VooDooMan
Version:
1
Date:
2004
Return values:
true If success
false If another instance is running (file "logs/irc_bot.pid" is blocked for unlink-ing)

Definition at line 568 of file log.cpp.

References FILE_SLASH, log_bot(), log_botnet(), log_botnet_debug(), log_debug(), log_initialized, log_irc(), log_socket(), pid, and posix_lock_file.

Referenced by main().

00569 {
00570 #ifdef _WIN32
00571     mkdir("logs");
00572 #else
00573     mkdir("./logs",0700);
00574 #endif
00575 
00576 #ifndef _WIN32
00577     int fd=open("logs" FILE_SLASH "irc_bot.lock",O_RDWR | O_CREAT);
00578     if(fd<0) {
00579         fd=-1;
00580         char* tmp=new char[strlen(strerror(errno))+1024];
00581         sprintf(tmp,"Error while open() #1 - LOCK file: %s",strerror(errno));
00582         log_bot(tmp);
00583         delete[] tmp;
00584     } else {
00585         struct flock lck;
00586         lck.l_type=F_RDLCK;
00587         lck.l_start=0;
00588         lck.l_whence=SEEK_SET;
00589         lck.l_len=0;
00590         lck.l_pid=0;
00591         int ec=fcntl(fd,F_GETLK,&lck);
00592         if(ec) {
00593             char* tmp=new char[strlen(strerror(errno))+1024];
00594             sprintf(tmp,"Error while fcntl() - getting lock parameters on LOCK file: %s",strerror(errno));
00595             log_bot(tmp);
00596             delete[] tmp;
00597         }
00598         if(ec==0 && lck.l_type!=F_UNLCK) {
00599             close(fd);
00600             return false;
00601         }
00602     
00603         char tmp[1024];
00604         sprintf(tmp,"%d\n",getpid());
00605         write(fd,tmp,strlen(tmp));
00606         close(fd);
00607         chmod("logs" FILE_SLASH "irc_bot.lock",0600);
00608         fd=open("logs" FILE_SLASH "irc_bot.lock",O_RDWR);
00609         if(fd<0) {
00610             fd=-1;
00611             char* tmp=new char[strlen(strerror(errno))+1024];
00612             sprintf(tmp,"Error while open() #2 - LOCK file: %s",strerror(errno));
00613             log_bot(tmp);
00614             delete[] tmp;
00615         } else {
00616             struct flock lck;
00617             lck.l_type=F_WRLCK;
00618             lck.l_start=strlen(tmp)-1;
00619             lck.l_whence=SEEK_SET;
00620             lck.l_len=1;
00621             lck.l_pid=getpid();
00622             int ec=fcntl(fd,F_SETLK,&lck);
00623             if(ec) {
00624                 char* tmp=new char[strlen(strerror(errno))+1024];
00625                 sprintf(tmp,"Error while fcntl() - setting lock parameters on LOCK file: %s",strerror(errno));
00626                 log_bot(tmp);
00627                 delete[] tmp;
00628             }
00629         }
00630     }
00631     posix_lock_file=fd;
00632 #endif
00633     {
00634         // erase test (works only on Win32!)
00635         int ec=unlink("logs" FILE_SLASH "irc_bot.pid");
00636         if(ec!=0 && errno==EACCES)
00637             return false;
00638     }
00639     FILE* f=fopen("logs" FILE_SLASH "irc_bot.pid","w");
00640     if(f) {
00641         fprintf(f,"%d\n",getpid());
00642         fclose(f);
00643         pid=fopen("logs" FILE_SLASH "irc_bot.pid","r");
00644     }
00645 
00646     if(!log_initialized) {
00647         char msg[1024];
00648         sprintf(msg,"Bot's pid is %d",getpid());
00649         log_bot(msg);
00650     }
00651 
00652     log_debug("BOT STARTUP!");
00653     log_irc(false,"BOT STARTUP!");
00654     log_socket(0,"","BOT STARTUP!");
00655     log_bot("BOT STARTUP!");
00656     log_botnet_debug("","",-1,-1,"BOT STARTUP!");
00657     log_botnet("","","BOT STARTUP!");
00658 
00659     return true;
00660 }

Here is the call graph for this function:

void log_irc bool  from_server,
const char *  msg
 

Writes debug string to file logs/irc.log and to stdout if log_echo_irc == true.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
from_server Set to true if message goes from server, false if it goes to server
msg The log message

Definition at line 190 of file log.cpp.

References FILE_SLASH, init_echoes(), log_echo_irc, log_initialized, log_irc_, logic_on_internal_event(), and PRIVATE_EVENT_SEVERITY_CODE_INFORMATIONAL.

Referenced by irc_connect(), irc_disconnect(), irc_loop_process_input(), irc_putserv_immediately(), log_init(), and logic_exec().

00191 {
00192     if(!log_initialized)
00193         init_echoes();
00194 
00195     if(log_irc_) {
00196         FILE* f=fopen("logs" FILE_SLASH "irc.log","a");
00197         if(f) {
00198             char now[128];
00199             time_t n=time(NULL);
00200             strcpy(now,ctime(&n));
00201             now[26-1-1]=0;
00202             fprintf(f,"%s%s%s%s%s\n",now," - ",(from_server?"IN ":"OUT")," : ",msg);
00203             fclose(f);
00204         }
00205     }
00206 
00207     if(log_echo_irc)
00208         printf("%s%s%s%s\n","IRC ",(from_server?"IN ":"OUT")," ",msg);
00209 
00210     logic_on_internal_event("@log@","irc",(from_server?"IN":"OUT"),"","",PRIVATE_EVENT_SEVERITY_CODE_INFORMATIONAL,msg,"");
00211 }

Here is the call graph for this function:

void log_socket int  sock_error,
const char *  os_msg,
const char *  msg
 

Writes debug string to file logs/socket.log and to stdout if log_echo_socket == true.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
sock_error OS's socket I/O error code
os_msg Message from OS describing socket I/O error
msg The log message

Definition at line 222 of file log.cpp.

References FILE_SLASH, init_echoes(), log_echo_socket, log_initialized, log_socket_, logic_on_internal_event(), ltoa(), and PRIVATE_EVENT_SEVERITY_CODE_INFORMATIONAL.

Referenced by botnet_loop(), botnet_send_command(), botnet_send_control(), dcc_loop(), dcc_make_server(), dcc_make_telnet_server(), irc_connect(), irc_loop_putserv(), irc_putserv_immediately(), irc_quoted_callback(), log_init(), sock_bind6(), sock_connect(), sock_resolve6(), and sock_reverse().

00223 {
00224     if(!log_initialized)
00225         init_echoes();
00226 
00227     if(log_socket_) {
00228         FILE* f=fopen("logs" FILE_SLASH "socket.log","a");
00229         if(f) {
00230             char now[128];
00231             time_t n=time(NULL);
00232             strcpy(now,ctime(&n));
00233             now[26-1-1]=0;
00234             fprintf(f,"%s%s%d%s%s%s%s%s\n",now,": OS socket error code: ",sock_error," ",os_msg," (",msg,")");
00235             fclose(f);
00236         }
00237     }
00238 
00239     if(log_echo_socket)
00240         printf("%s%s - %s\n","SOCKET  ",os_msg,msg);
00241 
00242     char tmp[128];
00243     logic_on_internal_event("@log@","socket",ltoa((long)sock_error,tmp,10),"","",PRIVATE_EVENT_SEVERITY_CODE_INFORMATIONAL,os_msg,msg);
00244 }

Here is the call graph for this function:

void log_ssl const char *  msg  ) 
 

Writes debug string to file logs/ssl.log and to stdout if log_echo_ssl == true.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
msg The log message

Definition at line 524 of file log.cpp.

References FILE_SLASH, init_echoes(), log_echo_ssl, log_initialized, log_ssl_, logic_on_internal_event(), and PRIVATE_EVENT_SEVERITY_CODE_INFORMATIONAL.

Referenced by ssl_client_connection(), ssl_do_read_write(), ssl_init(), ssl_process_error_on_verify(), ssl_server_connection(), ssl_server_read(), and ssl_write().

00525 {
00526     if(!log_initialized)
00527         init_echoes();
00528 
00529     char* msg2=new char[strlen(msg)+1];
00530     strcpy(msg2,msg);
00531     if(msg2[strlen(msg2)-1]=='\r')
00532         msg2[strlen(msg2)-1]=0;
00533     if(msg2[strlen(msg2)-1]=='\n')
00534         msg2[strlen(msg2)-1]=0;
00535     if(msg2[strlen(msg2)-1]=='\r')
00536         msg2[strlen(msg2)-1]=0;
00537     if(msg2[strlen(msg2)-1]=='\n')
00538         msg2[strlen(msg2)-1]=0;
00539 
00540     if(log_ssl_) {
00541         FILE* f=fopen("logs" FILE_SLASH "ssl.log","a");
00542         if(f) {
00543             char now[128];
00544             time_t n=time(NULL);
00545             strcpy(now,ctime(&n));
00546             now[26-1-1]=0;
00547             fprintf(f,"%s%s%s\n",now,": ",msg2);
00548             fclose(f);
00549         }
00550     }
00551 
00552     if(log_echo_ssl)
00553         printf("%s%s\n","OpenSSL ",msg2);
00554 
00555     logic_on_internal_event("@log@","ssl","","","",PRIVATE_EVENT_SEVERITY_CODE_INFORMATIONAL,msg2,"");
00556 
00557     delete[] msg2;
00558 }

Here is the call graph for this function:


Generated on Sun Jul 10 05:01:17 2005 for VooDoo cIRCle by doxygen 1.4.3

Hosted by SourceForge.net Logo