Skip to main content

Logging

The main purpose of logging is to record operations performed in a task for further analysis. Keeping logs provides the ability to identify errors in the task execution.

this.doLog

Shows whether task logging is enabled; it can be used as a flag for optimization in cases where logging is disabled and a complex expression is passed as an argument to this.logger.put.

this.logger.*

.put(message)

this.logger.put(message) - adds a message line to the task log, formatting the output similarly to console.log.

this.logger.put("Start scraping query: " + set.query);
Example of message output to the task log

.putHTML(HTML)

this.logger.putHTML(code) - outputs HTML code to the task log, which will be displayed in the textarea.

const message = "<!DOCTYPE html>\n"
+ "<html>\n"
+ "<body>\n"
+ "<h1>This is heading 1</h1>\n"
+ "<h2>This is heading 2</h2>\n"
+ "<h3>This is heading 3</h3>\n"
+ "<h4>This is heading 4</h4>\n"
+ "<h5>This is heading 5</h5>\n"
+ "<h6>This is heading 6</h6>\n"
+ "</body>\n"
+ "</html>";
this.logger.putHTML(message);
Example of html output to the task log

console.log(message)

Outputs the content of message to the log file - aparser.log.

this.console.*

All methods relate to console log output and are designed to improve logging for different tasks and different threads within tasks.

.log(...message)

this.console.log(...message) - logging linked to the current thread, allowing a prefix to be output for each thread.

.setPrefix(prefix)

Used in conjunction with BaseParser.setGlobalConsolePrefix(prefix) - allows setting a global prefix for all threads within the current task.

this.console.setPrefix(prefix) - allows setting a prefix for the current thread, for example:

this.console.setPrefix(this.threadId())