Skip to content

Log

Purpose

Provides log methods.

Methods

Binding name:

  • p6.log
  • log (deprecated)

Method: void trace(String message)

Generate a log message with the TRACE level.


Method: void trace(String message, Throwable exception)

Generate a log message, and an exception with the TRACE level.


Method: void debug(String message)

Generate a log message with the DEBUG level.


Method: void debug(String message, Throwable exception)

Generate a log message, and an exception with the DEBUG level.


Method: void info(String message)

Generate a log message with the INFO level.


Method: void info(String message, Throwable exception)

Generate a log message, and an exception with the INFO level.


Method: void warn(String message)

Generate a log message with the WARN level.


Method: void warn(String message, Throwable exception)

Generate a log message, and an exception with the WARN level.


Method: void error(String message)

Generate a log message with the ERROR level.


Method: void error(String message, Throwable exception)

Generate a log message, and an exception with the ERROR level.

Output

Every log call will generate:

[5-12-2020 16:40] <LEVEL> [GROOVYSCRIPT: <Logger name>] <Message>

The Logger name is equal to:

  • for script: io.platform6.scripts.p6core.<Script name>.Main
  • for route: io.platform6.routes.p6core.<Route name>_groovy.Main

Provided exceptions will only be visible inside the application log file and not inside the script output log.

Examples

def tables = p6.script.list()
p6.log.info("Searching for scripts")
p6.log.debug("Found " + tables.size() + " scripts")
p6.log.error("Oops", new io.platform6.common.util.P6Exception("Script list should be parsed"))

Will provide the output

[5-12-2020 16:40] INFO [GROOVYSCRIPT: io.platform6.scripts.p6core.MyScript.Main] Searching for scripts
[5-12-2020 16:40] DEBUG [GROOVYSCRIPT: io.platform6.scripts.p6core.MyScript.Main] Found 25 scripts
[5-12-2020 16:40] ERROR [GROOVYSCRIPT: io.platform6.scripts.p6core.MyScript.Main] Oops