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