1 /************************************************************************
2 * IRC - Internet Relay Chat, src/ircd_log.c
3 * Copyright (C) 1999 Thomas Helvey (BleepSoft)
5 * See file AUTHORS in IRC package for additional names of
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 1, or (at your option)
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 #include "ircd_string.h"
37 #define LOG_BUFSIZE 2048
39 static int logLevel = L_INFO;
42 static int sysLogLevel[] = {
53 void ircd_log(int priority, const char* fmt, ...)
55 #if defined(USE_SYSLOG) || defined(DEBUGMODE)
56 char buf[LOG_BUFSIZE];
58 assert(-1 < priority);
59 assert(priority < L_LAST_LEVEL);
62 if (priority > logLevel)
66 vsprintf(buf, fmt, args);
70 syslog(sysLogLevel[priority], "%s", buf);
73 Debug((DEBUG_INFO, "LOG: %s", buf));
77 void open_log(const char* process_name)
80 if (EmptyString(process_name))
81 process_name = "ircd";
82 openlog(process_name, LOG_PID | LOG_NDELAY, LOG_USER);
93 void set_log_level(int level)
95 if (L_ERROR < level && level < L_LAST_LEVEL)
99 int get_log_level(void)
105 * ircd_log_kill - log information about a kill
107 void ircd_log_kill(const struct Client* victim, const struct Client* killer,
108 const char* inpath, const char* path)
110 if (MyUser(victim)) {
112 * get more infos when your local clients are killed -- _dl
114 if (IsServer(killer))
116 "A local client %s!%s@%s KILLED from %s [%s] Path: %s!%s)",
117 victim->name, victim->user->username, victim->user->host,
118 killer->name, killer->name, inpath, path);
121 "A local client %s!%s@%s KILLED by %s [%s!%s@%s] (%s!%s)",
122 victim->name, victim->user->username, victim->user->host,
123 killer->name, killer->name, killer->user->username, killer->user->host,
127 ircd_log(L_TRACE, "KILL From %s For %s Path %s!%s",
128 killer->name, victim->name, inpath, path);