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