Changes between Version 7 and Version 8 of Logging


Ignore:
Timestamp:
Feb 10, 2023, 5:54:44 AM (15 months ago)
Author:
Langbart
Comment:

Add more examples of logging a debug message in JavaScript

Legend:

Unmodified
Added
Removed
Modified
  • Logging

    v7 v8  
    4242||`error` ||  Y  ||  Y - red text  ||  Y  ||  Y  ||  Y  ||  N  ||
    4343 
     44[[Debugging#Debuggingscripterrors|Debug]] by inserting logging functions.
     45{{{#!sh
     46# Most commonly used debug messages
    4447
    45 {{{#!sh
     48# Print an unknown variable
     49warn(uneval(arg))
     50
    4651# Print a debug message with several arguments.
    47 warn(uneval(['string', arg1, arg2]))
     52warn(uneval([arg1, arg2]))
     53
     54# Similar to uneval, but it does not show functions in that object
     55warn(JSON.stringify(object))
     56
     57# Create a stack trace of the JavaScript call stack at the moment that the Error object was created.
     58warn(new Error().stack)
     59
     60# Petra AI: automatically uneval and include the player ID
     61API3.warn(arg)
    4862}}}
    4963