java.lang.Object
org.daiitech.naftah.playground.utils.logging.Logger

public class Logger extends Object
Simple logger implementation used by the Naftah Playground.

This logger provides basic level-based logging and forwards log messages to the browser-hosted logging console through the NaftahPlayground bridge.

Messages are emitted only when the configured logger level permits the requested message level. Log output follows the format:

 [LEVEL] LoggerName - Message
 

This class is intended for lightweight runtime diagnostics within browser-hosted environments and is not designed as a replacement for full-featured logging frameworks.

Author:
Chakib Daii
  • Field Details

    • name

      private final String name
      Name of the logger, included in every log message.
    • level

      private LogLevel level
      Current logging level.
  • Constructor Details

    • Logger

      public Logger(String name, LogLevel level)
      Creates a logger with the specified name and logging level.
      Parameters:
      name - the logger name
      level - the minimum logging level to allow
  • Method Details

    • setLevel

      public void setLevel(LogLevel level)
      Updates the logger's active logging level.
      Parameters:
      level - the new logging level
    • error

      public void error(String msg)
      Logs an error message.
      Parameters:
      msg - the message to log
    • warn

      public void warn(String msg)
      Logs a warning message.
      Parameters:
      msg - the message to log
    • info

      public void info(String msg)
      Logs an informational message.
      Parameters:
      msg - the message to log
    • debug

      public void debug(String msg)
      Logs a debug message.
      Parameters:
      msg - the message to log
    • trace

      public void trace(String msg)
      Logs a trace message.
      Parameters:
      msg - the message to log
    • log

      private void log(LogLevel msgLevel, String msg)
      Logs a message at the specified level.

      If the current logger configuration allows the supplied level, the message is forwarded to the browser logging bridge. Any errors occurring during log delivery are silently ignored to prevent logging failures from affecting application execution.

      Parameters:
      msgLevel - the level of the message being logged
      msg - the message text