/addons/sourcemod/scripting/include/logging.inc

https://bitbucket.org/kimoto/sushi · Pascal · 153 lines · 151 code · 2 blank · 0 comment · 2 complexity · 938829efcd841a7e026b5f3b239d0b0f MD5 · raw file

  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. #if defined _sm_logging_included
  33. #endinput
  34. #endif
  35. #define _sm_logging_included
  36. /**
  37. * Logs a plugin message to the SourceMod logs. The log message will be
  38. * prefixed by the plugin's logtag (filename).
  39. *
  40. * @param format String format.
  41. * @param ... Format arguments.
  42. * @noreturn
  43. */
  44. native LogMessage(const String:format[], any:...);
  45. /**
  46. * Logs a message to the SourceMod logs without any plugin logtag. This is
  47. * useful for re-routing messages from other plugins, for example, messages
  48. * from LogAction().
  49. *
  50. * @param format String format.
  51. * @param ... Format arguments.
  52. * @noreturn
  53. */
  54. native LogMessageEx(const String:format[], any:...);
  55. /**
  56. * Logs a message to any file. The log message will be in the normal
  57. * SourceMod format, with the plugin logtag prepended.
  58. *
  59. * @param file File to write the log message in.
  60. * @param format String format.
  61. * @param ... Format arguments.
  62. * @noreturn
  63. * @error File could not be opened/written.
  64. */
  65. native LogToFile(const String:file[], const String:format[], any:...);
  66. /**
  67. * Same as LogToFile(), except no plugin logtag is prepended.
  68. *
  69. * @param file File to write the log message in.
  70. * @param format String format.
  71. * @param ... Format arguments.
  72. * @noreturn
  73. * @error File could not be opened/written.
  74. */
  75. native LogToFileEx(const String:file[], const String:format[], any:...);
  76. /**
  77. * Logs an action from a command or event whereby interception and routing may
  78. * be important. This is intended to be a logging version of ShowActivity().
  79. *
  80. * @param client Client performing the action, 0 for server, or -1 if not
  81. * applicable.
  82. * @param target Client being targetted, or -1 if not applicable.
  83. * @param message Message format.
  84. * @param ... Message formatting parameters.
  85. * @noreturn
  86. */
  87. native LogAction(client, target, const String:message[], any:...);
  88. /**
  89. * Logs a plugin error message to the SourceMod logs.
  90. *
  91. * @param format String format.
  92. * @param ... Format arguments.
  93. * @noreturn
  94. */
  95. native LogError(const String:format[], any:...);
  96. /**
  97. * Called when an action is going to be logged.
  98. *
  99. * @param source Handle to the object logging the action, or INVALID_HANDLE
  100. * if Core is logging the action.
  101. * @param ident Type of object logging the action (plugin, ext, or core).
  102. * @param client Client the action is from; 0 for server, -1 if not applicable.
  103. * @param target Client the action is targetting, or -1 if not applicable.
  104. * @param message Message that is being logged.
  105. * @return Plugin_Continue will cause Core to defaulty log the message.
  106. * Plugin_Handled will stop Core from logging the message.
  107. * Plugin_Stop is the same as Handled, but prevents any other
  108. * plugins from handling the message.
  109. */
  110. forward Action:OnLogAction(Handle:source,
  111. Identity:ident,
  112. client,
  113. target,
  114. const String:message[]);
  115. /**
  116. * Called when a game log message is received.
  117. *
  118. * Any Log*() functions called within this callback will not recursively
  119. * pass through. That is, they will log directly, bypassing this callback.
  120. *
  121. * Note that this does not capture log messages from the engine. It only
  122. * captures log messages being sent from the game/mod itself.
  123. *
  124. * @param message Message contents.
  125. * @return Plugin_Handled or Plugin_Stop will prevent the message
  126. * from being written to the log file.
  127. */
  128. functag public Action:GameLogHook(const String:message[]);
  129. /**
  130. * Adds a game log hook.
  131. *
  132. * @param hook Hook function.
  133. * @noreturn
  134. */
  135. native AddGameLogHook(GameLogHook:hook);
  136. /**
  137. * Removes a game log hook.
  138. *
  139. * @param hook Hook function.
  140. * @noreturn
  141. */
  142. native RemoveGameLogHook(GameLogHook:hook);