darope@0: // vi: set ts=4 sw=4 : darope@0: // vim: set tw=75 : darope@0: darope@0: // log_plugin.cpp - generic/common logging routines for plugin codebases darope@0: darope@0: /* darope@0: * Copyright (c) 2001-2003 Will Day darope@0: * darope@0: * This file is part of Metamod. darope@0: * darope@0: * Metamod is free software; you can redistribute it and/or modify it darope@0: * under the terms of the GNU General Public License as published by the darope@0: * Free Software Foundation; either version 2 of the License, or (at darope@0: * your option) any later version. darope@0: * darope@0: * Metamod is distributed in the hope that it will be useful, but darope@0: * WITHOUT ANY WARRANTY; without even the implied warranty of darope@0: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU darope@0: * General Public License for more details. darope@0: * darope@0: * You should have received a copy of the GNU General Public License darope@0: * along with Metamod; if not, write to the Free Software Foundation, darope@0: * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA darope@0: * darope@0: * In addition, as a special exception, the author gives permission to darope@0: * link the code of this program with the Half-Life Game Engine ("HL darope@0: * Engine") and Modified Game Libraries ("MODs") developed by Valve, darope@0: * L.L.C ("Valve"). You must obey the GNU General Public License in all darope@0: * respects for all of the code used other than the HL Engine and MODs darope@0: * from Valve. If you modify this file, you may extend this exception darope@0: * to your version of the file, but you are not obligated to do so. If darope@0: * you do not wish to do so, delete this exception statement from your darope@0: * version. darope@0: * darope@0: */ darope@0: darope@0: #include // vsnprintf(), etc darope@0: #include // va_start(), etc darope@0: darope@0: #include darope@0: #include // ALERT() darope@0: darope@0: #include darope@0: #include darope@0: darope@0: #include "log_plugin.h" darope@0: #include "plugin.h" darope@0: darope@0: cvar_t *plugin_debug; darope@0: darope@0: // Setup for logging. We pass the name of the debug cvar so that this darope@0: // code can be used by multiple different plugins. darope@0: void log_init(const char *cvarname) { darope@0: CVAR_REGISTER(&init_plugin_debug); darope@0: // Since metamod replaces our cvar_t structure with a structure local darope@0: // to metamod when we call CVAR_REGISTER, we have to get the address of darope@0: // the new struct if we expect to be able to read/write directly to darope@0: // the cvar struct. darope@0: plugin_debug=CVAR_GET_POINTER(cvarname); darope@0: // Since we haven't read server.cfg yet, allow debug logging (level 3) darope@0: // to be enabled with the "+developer" cmdline option. darope@0: if((int) CVAR_GET_FLOAT("developer") != 0) darope@0: CVAR_SET_FLOAT(cvarname, 3); darope@0: }