Skip to content

Logger

Logs informational messages that provide general feedback or updates.

Logger.info("Server has started successfully.");

Logs standard messages, typically for routine operations.

Logger.log("User connected to the service.");

Logs debug messages intended for development or troubleshooting purposes.

Logger.debug(
"Debugging connection parameters: { host: 'localhost', port: 3431 }"
);

Logs warning messages to signal potential problems or caution.

Logger.warn("Disk usage is nearing capacity.");

Logs error messages, useful for reporting issues or exceptions.

Logger.error("Failed to connect to the database.");

Here’s an example of using the Logger utility to track server operations:

Logger.info("Server is starting...");
Logger.log("Listening on port 3431.");
try {
// Simulating a successful operation
Logger.debug("Attempting to connect to the database...");
// Simulated operation succeeded
Logger.info("Connected to the database successfully.");
} catch (error) {
Logger.error("Database connection failed: " + error.message);
}

  • Use Logger.info for high-level updates and progress.
  • Use Logger.log for normal operations and tracking.
  • Use Logger.debug during development to trace issues or inspect application behavior.
  • Use Logger.warn for important warnings or risks that aren’t critical errors.
  • Use Logger.error for critical failures or exceptions.

Additional utility modules may be introduced to expand GamanJS functionality. Stay tuned for updates in future releases.

For more advanced usage and examples, refer to the GamanJS documentation or code samples.