Class PLog

java.lang.Object
com.petarmc.lib.log.PLog
All Implemented Interfaces:
PLogger

public class PLog extends Object implements PLogger
PerformanceLog implementation that logs messages to the console and optionally to a file. Designed to track debug, info, warning, and error messages with optional thread information.
  • Field Details

    • name

      private final String name
  • Constructor Details

    • PLog

      public PLog(String name)
      Creates a new PerformanceLog instance with the given name.
      Parameters:
      name - the name of the logger, typically representing the class or module
  • Method Details

    • getName

      public String getName()
      Returns the name of this logger.
      Specified by:
      getName in interface PLogger
      Returns:
      the logger name
    • format

      private String format(String level, String msg)
    • writeToFile

      private void writeToFile(String line)
    • allowed

      private boolean allowed(LogLevel level)
    • debug

      public void debug(String msg)
      Logs a debug-level message.
      Specified by:
      debug in interface PLogger
      Parameters:
      msg - the message to log
    • info

      public void info(String msg)
      Logs an info-level message. Ignored if LogConfig.enforceLevel is true and the global log level is higher than INFO.
      Specified by:
      info in interface PLogger
      Parameters:
      msg - the message to log
    • warn

      public void warn(String msg)
      Logs a warning-level message.
      Specified by:
      warn in interface PLogger
      Parameters:
      msg - the message to log
    • error

      public void error(String msg)
      Logs an error-level message.
      Specified by:
      error in interface PLogger
      Parameters:
      msg - the message to log
    • error

      public void error(String msg, Throwable t)
      Logs an error-level message along with a Throwable. Prints the exception's stack trace and message.
      Specified by:
      error in interface PLogger
      Parameters:
      msg - the message to log
      t - the Throwable to include in the log