You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

307 lines
8.0 KiB

  1. //wrapper macros for easier grepping
  2. #define DIRECT_OUTPUT(A, B) A << B
  3. #define SEND_IMAGE(target, image) DIRECT_OUTPUT(target, image)
  4. #define SEND_SOUND(target, sound) DIRECT_OUTPUT(target, sound)
  5. #define SEND_TEXT(target, text) DIRECT_OUTPUT(target, text)
  6. #define WRITE_FILE(file, text) DIRECT_OUTPUT(file, text)
  7. //This is an external call, "true" and "false" are how rust parses out booleans
  8. #define WRITE_LOG(log, text) rustg_log_write(log, text, "true")
  9. #define WRITE_LOG_NO_FORMAT(log, text) rustg_log_write(log, text, "false")
  10. //print a warning message to world.log
  11. #define WARNING(MSG) warning("[MSG] in [__FILE__] at line [__LINE__] src: [UNLINT(src)] usr: [usr].")
  12. /proc/warning(msg)
  13. msg = "## WARNING: [msg]"
  14. log_world(msg)
  15. //not an error or a warning, but worth to mention on the world log, just in case.
  16. #define NOTICE(MSG) notice(MSG)
  17. /proc/notice(msg)
  18. msg = "## NOTICE: [msg]"
  19. log_world(msg)
  20. //print a testing-mode debug message to world.log and world
  21. #ifdef TESTING
  22. #define testing(msg) log_world("## TESTING: [msg]"); to_chat(world, "## TESTING: [msg]")
  23. #else
  24. #define testing(msg)
  25. #endif
  26. #ifdef UNIT_TESTS
  27. /proc/log_test(text)
  28. WRITE_LOG(GLOB.test_log, text)
  29. SEND_TEXT(world.log, text)
  30. #endif
  31. /* Items with ADMINPRIVATE prefixed are stripped from public logs. */
  32. /proc/log_admin(text)
  33. GLOB.admin_log.Add(text)
  34. if (CONFIG_GET(flag/log_admin))
  35. WRITE_LOG(GLOB.world_game_log, "ADMIN: [text]")
  36. /proc/log_admin_private(text)
  37. GLOB.admin_log.Add(text)
  38. if (CONFIG_GET(flag/log_admin))
  39. WRITE_LOG(GLOB.world_game_log, "ADMINPRIVATE: [text]")
  40. /proc/log_adminsay(text)
  41. GLOB.admin_log.Add(text)
  42. if (CONFIG_GET(flag/log_adminchat))
  43. WRITE_LOG(GLOB.world_game_log, "ADMINPRIVATE: ASAY: [text]")
  44. /proc/log_dsay(text)
  45. if (CONFIG_GET(flag/log_adminchat))
  46. WRITE_LOG(GLOB.world_game_log, "ADMIN: DSAY: [text]")
  47. /* All other items are public. */
  48. /proc/log_game(text)
  49. if (CONFIG_GET(flag/log_game))
  50. WRITE_LOG(GLOB.world_game_log, "GAME: [text]")
  51. /proc/log_mecha(text)
  52. if (CONFIG_GET(flag/log_mecha))
  53. WRITE_LOG(GLOB.world_mecha_log, "MECHA: [text]")
  54. /proc/log_virus(text)
  55. if (CONFIG_GET(flag/log_virus))
  56. WRITE_LOG(GLOB.world_virus_log, "VIRUS: [text]")
  57. /proc/log_cloning(text, mob/initiator)
  58. if(CONFIG_GET(flag/log_cloning))
  59. WRITE_LOG(GLOB.world_cloning_log, "CLONING: [text]")
  60. /proc/log_paper(text)
  61. WRITE_LOG(GLOB.world_paper_log, "PAPER: [text]")
  62. /proc/log_asset(text)
  63. WRITE_LOG(GLOB.world_asset_log, "ASSET: [text]")
  64. /proc/log_access(text)
  65. if (CONFIG_GET(flag/log_access))
  66. WRITE_LOG(GLOB.world_game_log, "ACCESS: [text]")
  67. /proc/log_law(text)
  68. if (CONFIG_GET(flag/log_law))
  69. WRITE_LOG(GLOB.world_game_log, "LAW: [text]")
  70. /proc/log_attack(text)
  71. if (CONFIG_GET(flag/log_attack))
  72. WRITE_LOG(GLOB.world_attack_log, "ATTACK: [text]")
  73. /proc/log_manifest(ckey, datum/mind/mind,mob/body, latejoin = FALSE)
  74. if (CONFIG_GET(flag/log_manifest))
  75. WRITE_LOG(GLOB.world_manifest_log, "[ckey] \\ [body.real_name] \\ [mind.assigned_role] \\ [mind.special_role ? mind.special_role : "NONE"] \\ [latejoin ? "LATEJOIN":"ROUNDSTART"]")
  76. /proc/log_bomber(atom/user, details, atom/bomb, additional_details, message_admins = TRUE)
  77. var/bomb_message = "[details][bomb ? " [bomb.name] at [AREACOORD(bomb)]": ""][additional_details ? " [additional_details]" : ""]."
  78. if(user)
  79. user.log_message(bomb_message, LOG_GAME) //let it go to individual logs as well as the game log
  80. bomb_message = "[key_name(user)] at [AREACOORD(user)] [bomb_message]"
  81. else
  82. log_game(bomb_message)
  83. GLOB.bombers += bomb_message
  84. if(message_admins)
  85. message_admins("[user ? "[ADMIN_LOOKUPFLW(user)] at [ADMIN_VERBOSEJMP(user)] " : ""][details][bomb ? " [bomb.name] at [ADMIN_VERBOSEJMP(bomb)]": ""][additional_details ? " [additional_details]" : ""].")
  86. /proc/log_say(text)
  87. if (CONFIG_GET(flag/log_say))
  88. WRITE_LOG(GLOB.world_game_log, "SAY: [text]")
  89. /proc/log_ooc(text)
  90. if (CONFIG_GET(flag/log_ooc))
  91. WRITE_LOG(GLOB.world_game_log, "OOC: [text]")
  92. /proc/log_whisper(text)
  93. if (CONFIG_GET(flag/log_whisper))
  94. WRITE_LOG(GLOB.world_game_log, "WHISPER: [text]")
  95. /proc/log_emote(text)
  96. if (CONFIG_GET(flag/log_emote))
  97. WRITE_LOG(GLOB.world_game_log, "EMOTE: [text]")
  98. /proc/log_prayer(text)
  99. if (CONFIG_GET(flag/log_prayer))
  100. WRITE_LOG(GLOB.world_game_log, "PRAY: [text]")
  101. /proc/log_pda(text)
  102. if (CONFIG_GET(flag/log_pda))
  103. WRITE_LOG(GLOB.world_pda_log, "PDA: [text]")
  104. /proc/log_comment(text)
  105. if (CONFIG_GET(flag/log_pda))
  106. //reusing the PDA option because I really don't think news comments are worth a config option
  107. WRITE_LOG(GLOB.world_pda_log, "COMMENT: [text]")
  108. /proc/log_telecomms(text)
  109. if (CONFIG_GET(flag/log_telecomms))
  110. WRITE_LOG(GLOB.world_telecomms_log, "TCOMMS: [text]")
  111. /proc/log_chat(text)
  112. if (CONFIG_GET(flag/log_pda))
  113. //same thing here
  114. WRITE_LOG(GLOB.world_pda_log, "CHAT: [text]")
  115. /proc/log_vote(text)
  116. if (CONFIG_GET(flag/log_vote))
  117. WRITE_LOG(GLOB.world_game_log, "VOTE: [text]")
  118. /proc/log_shuttle(text)
  119. if (CONFIG_GET(flag/log_shuttle))
  120. WRITE_LOG(GLOB.world_shuttle_log, "SHUTTLE: [text]")
  121. /proc/log_topic(text)
  122. WRITE_LOG(GLOB.world_game_log, "TOPIC: [text]")
  123. /proc/log_href(text)
  124. WRITE_LOG(GLOB.world_href_log, "HREF: [text]")
  125. /proc/log_sql(text)
  126. WRITE_LOG(GLOB.sql_error_log, "SQL: [text]")
  127. /proc/log_qdel(text)
  128. WRITE_LOG(GLOB.world_qdel_log, "QDEL: [text]")
  129. /proc/log_query_debug(text)
  130. WRITE_LOG(GLOB.query_debug_log, "SQL: [text]")
  131. /proc/log_job_debug(text)
  132. if (CONFIG_GET(flag/log_job_debug))
  133. WRITE_LOG(GLOB.world_job_debug_log, "JOB: [text]")
  134. /* Log to both DD and the logfile. */
  135. /proc/log_world(text)
  136. #ifdef USE_CUSTOM_ERROR_HANDLER
  137. WRITE_LOG(GLOB.world_runtime_log, text)
  138. #endif
  139. SEND_TEXT(world.log, text)
  140. /* Log to the logfile only. */
  141. /proc/log_runtime(text)
  142. WRITE_LOG(GLOB.world_runtime_log, text)
  143. /* Rarely gets called; just here in case the config breaks. */
  144. /proc/log_config(text)
  145. WRITE_LOG(GLOB.config_error_log, text)
  146. SEND_TEXT(world.log, text)
  147. /proc/log_mapping(text)
  148. WRITE_LOG(GLOB.world_map_error_log, text)
  149. /* ui logging */
  150. /proc/log_tgui(text)
  151. WRITE_LOG(GLOB.tgui_log, text)
  152. /* For logging round startup. */
  153. /proc/start_log(log)
  154. WRITE_LOG(log, "Starting up round ID [GLOB.round_id].\n-------------------------")
  155. /* Close open log handles. This should be called as late as possible, and no logging should hapen after. */
  156. /proc/shutdown_logging()
  157. rustg_log_close_all()
  158. /* Helper procs for building detailed log lines */
  159. /proc/key_name(whom, include_link = null, include_name = TRUE)
  160. var/mob/M
  161. var/client/C
  162. var/key
  163. var/ckey
  164. var/fallback_name
  165. if(!whom)
  166. return "*null*"
  167. if(istype(whom, /client))
  168. C = whom
  169. M = C.mob
  170. key = C.key
  171. ckey = C.ckey
  172. else if(ismob(whom))
  173. M = whom
  174. C = M.client
  175. key = M.key
  176. ckey = M.ckey
  177. else if(istext(whom))
  178. key = whom
  179. ckey = ckey(whom)
  180. C = GLOB.directory[ckey]
  181. if(C)
  182. M = C.mob
  183. else if(istype(whom,/datum/mind))
  184. var/datum/mind/mind = whom
  185. key = mind.key
  186. ckey = ckey(key)
  187. if(mind.current)
  188. M = mind.current
  189. if(M.client)
  190. C = M.client
  191. else
  192. fallback_name = mind.name
  193. else // Catch-all cases if none of the types above match
  194. var/swhom = null
  195. if(istype(whom, /atom))
  196. var/atom/A = whom
  197. swhom = "[A.name]"
  198. else if(istype(whom, /datum))
  199. swhom = "[whom]"
  200. if(!swhom)
  201. swhom = "*invalid*"
  202. return "\[[swhom]\]"
  203. . = ""
  204. if(!ckey)
  205. include_link = FALSE
  206. if(key)
  207. if(C && C.holder && C.holder.fakekey && !include_name)
  208. if(include_link)
  209. . += "<a href='?priv_msg=[C.findStealthKey()]'>"
  210. . += "Administrator"
  211. else
  212. if(include_link)
  213. . += "<a href='?priv_msg=[ckey]'>"
  214. . += key
  215. if(!C)
  216. . += "\[DC\]"
  217. if(include_link)
  218. . += "</a>"
  219. else
  220. . += "*no key*"
  221. if(include_name)
  222. if(M)
  223. if(M.real_name)
  224. . += "/([M.real_name])"
  225. else if(M.name)
  226. . += "/([M.name])"
  227. else if(fallback_name)
  228. . += "/([fallback_name])"
  229. return .
  230. /proc/key_name_admin(whom, include_name = TRUE)
  231. return key_name(whom, TRUE, include_name)
  232. /proc/loc_name(atom/A)
  233. if(!istype(A))
  234. return "(INVALID LOCATION)"
  235. var/turf/T = A
  236. if (!istype(T))
  237. T = get_turf(A)
  238. if(istype(T))
  239. return "([AREACOORD(T)])"
  240. else if(A.loc)
  241. return "(UNKNOWN (?, ?, ?))"