plugins/include/logging.inc
author David Anderson <dvander@alliedmods.net>
Sat May 17 05:12:52 2008 +0000 (2008-05-17)
changeset 2056 f1fcde46ac7c
parent 1952 b7aa2b626807
child 2289 44045ead61cd
permissions -rw-r--r--
added amb1119 - sm_revote command
ds@1952
     1
/**
ds@1952
     2
 * vim: set ts=4 :
ds@1952
     3
 * =============================================================================
ds@1952
     4
 * SourceMod (C)2004-2008 AlliedModders LLC.  All rights reserved.
ds@1952
     5
 * =============================================================================
ds@1952
     6
 *
ds@1952
     7
 * This file is part of the SourceMod/SourcePawn SDK.
ds@1952
     8
 *
ds@1952
     9
 * This program is free software; you can redistribute it and/or modify it under
ds@1952
    10
 * the terms of the GNU General Public License, version 3.0, as published by the
ds@1952
    11
 * Free Software Foundation.
ds@1952
    12
 * 
ds@1952
    13
 * This program is distributed in the hope that it will be useful, but WITHOUT
ds@1952
    14
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
ds@1952
    15
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
ds@1952
    16
 * details.
ds@1952
    17
 *
ds@1952
    18
 * You should have received a copy of the GNU General Public License along with
ds@1952
    19
 * this program.  If not, see <http://www.gnu.org/licenses/>.
ds@1952
    20
 *
ds@1952
    21
 * As a special exception, AlliedModders LLC gives you permission to link the
ds@1952
    22
 * code of this program (as well as its derivative works) to "Half-Life 2," the
ds@1952
    23
 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
ds@1952
    24
 * by the Valve Corporation.  You must obey the GNU General Public License in
ds@1952
    25
 * all respects for all other code used.  Additionally, AlliedModders LLC grants
ds@1952
    26
 * this exception to all derivative works.  AlliedModders LLC defines further
ds@1952
    27
 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
ds@1952
    28
 * or <http://www.sourcemod.net/license.php>.
ds@1952
    29
 *
ds@1952
    30
 * Version: $Id$
ds@1952
    31
 */
ds@1952
    32
 
ds@1952
    33
#if defined _sm_logging_included
ds@1952
    34
 #endinput
ds@1952
    35
#endif
ds@1952
    36
#define _sm_logging_included
ds@1952
    37
ds@1952
    38
/**
ds@1952
    39
 * Logs a plugin message to the SourceMod logs.  The log message will be 
ds@1952
    40
 * prefixed by the plugin's logtag (filename).
ds@1952
    41
 *
ds@1952
    42
 * @param format		String format.
ds@1952
    43
 * @param ...			Format arguments.
ds@1952
    44
 * @noreturn
ds@1952
    45
 */
ds@1952
    46
native LogMessage(const String:format[], any:...);
ds@1952
    47
ds@1952
    48
/**
ds@1952
    49
 * Logs a message to the SourceMod logs without any plugin logtag.  This is 
ds@1952
    50
 * useful for re-routing messages from other plugins, for example, messages 
ds@1952
    51
 * from LogAction().
ds@1952
    52
 *
ds@1952
    53
 * @param format		String format.
ds@1952
    54
 * @param ...			Format arguments.
ds@1952
    55
 * @noreturn
ds@1952
    56
 */
ds@1952
    57
native LogMessageEx(const String:format[], any:...);
ds@1952
    58
ds@1952
    59
/**
ds@1952
    60
 * Logs a message to any file.  The log message will be in the normal 
ds@1952
    61
 * SourceMod format, with the plugin logtag prepended.
ds@1952
    62
 *
ds@1952
    63
 * @param file			File to write the log message in.
ds@1952
    64
 * @param format		String format.
ds@1952
    65
 * @param ...			Format arguments.
ds@1952
    66
 * @noreturn
ds@1952
    67
 * @error				File could not be opened/written.
ds@1952
    68
 */
ds@1952
    69
native LogToFile(const String:file[], const String:format[], any:...);
ds@1952
    70
ds@1952
    71
/**
ds@1952
    72
 * Same as LogToFile(), except no plugin logtag is prepended.
ds@1952
    73
 *
ds@1952
    74
 * @param file			File to write the log message in.
ds@1952
    75
 * @param format		String format.
ds@1952
    76
 * @param ...			Format arguments.
ds@1952
    77
 * @noreturn
ds@1952
    78
 * @error				File could not be opened/written.
ds@1952
    79
 */
ds@1952
    80
native LogToFileEx(const String:file[], const String:format[], any:...);
ds@1952
    81
ds@1952
    82
/**
ds@1952
    83
 * Logs an action from a command or event whereby interception and routing may 
ds@1952
    84
 * be important.  This is intended to be a logging version of ShowActivity().
ds@1952
    85
 *
ds@1952
    86
 * @param client		Client performing the action, 0 for server, or -1 if not 
ds@1952
    87
 *						applicable.
ds@1952
    88
 * @param target		Client being targetted, or -1 if not applicable.
ds@1952
    89
 * @param message		Message format.
ds@1952
    90
 * @param ...			Message formatting parameters.
ds@1952
    91
 * @noreturn
ds@1952
    92
 */
ds@1952
    93
native LogAction(client, target, const String:message[], any:...);
ds@1952
    94
ds@1952
    95
/**
ds@1952
    96
 * Logs a plugin error message to the SourceMod logs.
ds@1952
    97
 *
ds@1952
    98
 * @param format		String format.
ds@1952
    99
 * @param ...			Format arguments.
ds@1952
   100
 * @noreturn
ds@1952
   101
 */
ds@1952
   102
native LogError(const String:format[], any:...);
ds@1952
   103
ds@1952
   104
/**
ds@1952
   105
 * Called when an action is going to be logged.
ds@1952
   106
 *
ds@1952
   107
 * @param source		Handle to the object logging the action, or INVALID_HANDLE 
ds@1952
   108
 *						if Core is logging the action.
ds@1952
   109
 * @param ident			Type of object logging the action (plugin, ext, or core).
ds@1952
   110
 * @param client		Client the action is from; 0 for server, -1 if not applicable.
ds@1952
   111
 * @param target		Client the action is targetting, or -1 if not applicable.
ds@1952
   112
 * @param message		Message that is being logged.
ds@1952
   113
 * @return				Plugin_Continue will cause Core to defaulty log the message.
ds@1952
   114
 *						Plugin_Handled will stop Core from logging the message.
ds@1952
   115
 * 						Plugin_Stop is the same as Handled, but prevents any other 
ds@1952
   116
 *						plugins from handling the message.
ds@1952
   117
 */
ds@1952
   118
forward Action:OnLogAction(Handle:source, 
ds@1952
   119
						   Identity:ident,
ds@1952
   120
						   client,
ds@1952
   121
						   target,
ds@1952
   122
						   const String:message[]);
ds@1952
   123
ds@1952
   124
/**
ds@1952
   125
 * Called when a game log message is received.
ds@1952
   126
 *
ds@1952
   127
 * Any Log*() functions called within this callback will not recursively 
ds@1952
   128
 * pass through.  That is, they will log directly, bypassing this callback.
ds@1952
   129
 *
ds@1952
   130
 * Note that this does not capture log messages from the engine.  It only 
ds@1952
   131
 * captures log messages being sent from the game/mod itself.
ds@1952
   132
 *
ds@1952
   133
 * @param message		Message contents.
ds@1952
   134
 * @return				Plugin_Handled or Plugin_Stop will prevent the message 
ds@1952
   135
 * 						from being written to the log file.
ds@1952
   136
 */
ds@1952
   137
functag GameLogHook Action:public(const String:message[]);
ds@1952
   138
ds@1952
   139
/**
ds@1952
   140
 * Adds a game log hook.
ds@1952
   141
 *
ds@1952
   142
 * @param hook			Hook function.
ds@1952
   143
 * @noreturn
ds@1952
   144
 */
ds@1952
   145
native AddGameLogHook(GameLogHook:hook);
ds@1952
   146
ds@1952
   147
/**
ds@1952
   148
 * Removes a game log hook.
ds@1952
   149
 *
ds@1952
   150
 * @param hook			Hook function.
ds@1952
   151
 * @noreturn
ds@1952
   152
 */
ds@1952
   153
native RemoveGameLogHook(GameLogHook:hook);