dvander@1914: /**
dvander@1914: * vim: set ts=4 :
dvander@1914: * =============================================================================
ds@1947: * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
dvander@1914: * =============================================================================
dvander@1914: *
dvander@1914: * This file is part of the SourceMod/SourcePawn SDK.
dvander@1914: *
dvander@1914: * This program is free software; you can redistribute it and/or modify it under
dvander@1914: * the terms of the GNU General Public License, version 3.0, as published by the
dvander@1914: * Free Software Foundation.
dvander@1914: *
dvander@1914: * This program is distributed in the hope that it will be useful, but WITHOUT
dvander@1914: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
dvander@1914: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
dvander@1914: * details.
dvander@1914: *
dvander@1914: * You should have received a copy of the GNU General Public License along with
dvander@1914: * this program. If not, see .
dvander@1914: *
dvander@1914: * As a special exception, AlliedModders LLC gives you permission to link the
dvander@1914: * code of this program (as well as its derivative works) to "Half-Life 2," the
dvander@1914: * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
dvander@1914: * by the Valve Corporation. You must obey the GNU General Public License in
dvander@1914: * all respects for all other code used. Additionally, AlliedModders LLC grants
dvander@1914: * this exception to all derivative works. AlliedModders LLC defines further
dvander@1914: * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
dvander@1914: * or .
dvander@1914: *
dvander@1914: * Version: $Id$
dvander@1914: */
dvander@1914:
dvander@1914: #if defined _sm_logging_included
dvander@1914: #endinput
dvander@1914: #endif
dvander@1914: #define _sm_logging_included
dvander@1914:
dvander@1914: /**
dvander@1914: * Logs a plugin message to the SourceMod logs. The log message will be
dvander@1914: * prefixed by the plugin's logtag (filename).
dvander@1914: *
dvander@1914: * @param format String format.
dvander@1914: * @param ... Format arguments.
dvander@1914: * @noreturn
dvander@1914: */
dvander@1914: native LogMessage(const String:format[], any:...);
dvander@1914:
dvander@1914: /**
dvander@1914: * Logs a message to the SourceMod logs without any plugin logtag. This is
dvander@1914: * useful for re-routing messages from other plugins, for example, messages
dvander@1914: * from LogAction().
dvander@1914: *
dvander@1914: * @param format String format.
dvander@1914: * @param ... Format arguments.
dvander@1914: * @noreturn
dvander@1914: */
dvander@1914: native LogMessageEx(const String:format[], any:...);
dvander@1914:
dvander@1914: /**
dvander@1914: * Logs a message to any file. The log message will be in the normal
dvander@1914: * SourceMod format, with the plugin logtag prepended.
dvander@1914: *
dvander@1914: * @param file File to write the log message in.
dvander@1914: * @param format String format.
dvander@1914: * @param ... Format arguments.
dvander@1914: * @noreturn
dvander@1914: * @error File could not be opened/written.
dvander@1914: */
dvander@1914: native LogToFile(const String:file[], const String:format[], any:...);
dvander@1914:
dvander@1914: /**
dvander@1914: * Same as LogToFile(), except no plugin logtag is prepended.
dvander@1914: *
dvander@1914: * @param file File to write the log message in.
dvander@1914: * @param format String format.
dvander@1914: * @param ... Format arguments.
dvander@1914: * @noreturn
dvander@1914: * @error File could not be opened/written.
dvander@1914: */
dvander@1914: native LogToFileEx(const String:file[], const String:format[], any:...);
dvander@1914:
dvander@1914: /**
dvander@1914: * Logs an action from a command or event whereby interception and routing may
dvander@1914: * be important. This is intended to be a logging version of ShowActivity().
dvander@1914: *
dvander@1914: * @param client Client performing the action, 0 for server, or -1 if not
dvander@1914: * applicable.
dvander@1914: * @param target Client being targetted, or -1 if not applicable.
dvander@1914: * @param message Message format.
dvander@1914: * @param ... Message formatting parameters.
dvander@1914: * @noreturn
dvander@1914: */
dvander@1914: native LogAction(client, target, const String:message[], any:...);
dvander@1914:
dvander@1914: /**
dvander@1914: * Logs a plugin error message to the SourceMod logs.
dvander@1914: *
dvander@1914: * @param format String format.
dvander@1914: * @param ... Format arguments.
dvander@1914: * @noreturn
dvander@1914: */
dvander@1914: native LogError(const String:format[], any:...);
dvander@1914:
dvander@1914: /**
dvander@1914: * Called when an action is going to be logged.
dvander@1914: *
dvander@1914: * @param source Handle to the object logging the action, or INVALID_HANDLE
dvander@1914: * if Core is logging the action.
dvander@1914: * @param ident Type of object logging the action (plugin, ext, or core).
dvander@1914: * @param client Client the action is from; 0 for server, -1 if not applicable.
dvander@1914: * @param target Client the action is targetting, or -1 if not applicable.
dvander@1914: * @param message Message that is being logged.
dvander@1914: * @return Plugin_Continue will cause Core to defaulty log the message.
dvander@1914: * Plugin_Handled will stop Core from logging the message.
dvander@1914: * Plugin_Stop is the same as Handled, but prevents any other
dvander@1914: * plugins from handling the message.
dvander@1914: */
dvander@1914: forward Action:OnLogAction(Handle:source,
dvander@1914: Identity:ident,
dvander@1914: client,
dvander@1914: target,
dvander@1914: const String:message[]);
dvander@1914:
dvander@1914: /**
dvander@1914: * Called when a game log message is received.
dvander@1914: *
dvander@1914: * Any Log*() functions called within this callback will not recursively
dvander@1914: * pass through. That is, they will log directly, bypassing this callback.
dvander@1914: *
dvander@1914: * Note that this does not capture log messages from the engine. It only
dvander@1914: * captures log messages being sent from the game/mod itself.
dvander@1914: *
dvander@1914: * @param message Message contents.
dvander@1914: * @return Plugin_Handled or Plugin_Stop will prevent the message
dvander@1914: * from being written to the log file.
dvander@1914: */
dvander@2317: functag public Action:GameLogHook(const String:message[]);
dvander@1914:
dvander@1914: /**
dvander@1914: * Adds a game log hook.
dvander@1914: *
dvander@1914: * @param hook Hook function.
dvander@1914: * @noreturn
dvander@1914: */
dvander@1914: native AddGameLogHook(GameLogHook:hook);
dvander@1914:
dvander@1914: /**
dvander@1914: * Removes a game log hook.
dvander@1914: *
dvander@1914: * @param hook Hook function.
dvander@1914: * @noreturn
dvander@1914: */
dvander@1914: native RemoveGameLogHook(GameLogHook:hook);