Logging

Logger Class

The Logger class is designed to facilitate logging within your application. It provides various log levels to categorize and differentiate the type and severity of log messages.

You can use this class to record important information, debug messages, warnings, and errors during the execution of your application.

Methods

info(format: String, ...args?: any[]): void

Use this method to log informational messages. It accepts a format string and optional additional arguments that can be interpolated into the format string.

These messages are typically used to convey important details about the application's operation.

// Log informational message
Logger.info("This is an informational message.");

debug(format: String, ...args?: any[]): void

The debug method is intended for logging debugging messages. Like info, it also accepts a format string and optional arguments.

Debugging messages help developers understand the inner workings of the application and troubleshoot issues during development and testing.

// Log debugging message with interpolated argument
var variable = 42;
Logger.debug("Debugging message: %s", variable);

warn(format: String, ...args?: any[]): void

To log warning messages, use the warn method. It accepts a format string and optional arguments.

Warning messages are crucial for notifying users or developers about potential issues that do not disrupt the application's flow but should be addressed.

// Log a warning message
Logger.warn("Warning: Something might be wrong.");

error(format: String, ...args?: any[]): void

The error method is designed to log error messages. It accepts a format string and optional arguments.

Error messages are essential for identifying critical issues that need immediate attention and resolution. They help pinpoint problems in the application.

// Log an error message
Logger.error("Error: Something went terribly wrong.");

Last updated