Class SkriptLogger

java.lang.Object
io.github.syst3ms.skriptparser.log.SkriptLogger

public class SkriptLogger extends Object
An object through which Skript can keep track of errors, warnings and other useful information to the one that writes Skript code.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    SkriptLogger(boolean debug)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Decrements the recursion of the logger ; should be called after calling methods that may use SkriptLogger later in execution.
    void
    Clears every log that is an error message.
    void
    Clears every log that is not a debug message.
    void
    Clears every log that is not an error or a debug message.
    Finishes this Logger object, making it impossible to edit.
    void
    debug(String message)
    Logs a debug message.
    void
    error(String message, ErrorType errorType)
    Logs an error message
    void
    error(String message, ErrorType errorType, @Nullable String tip)
    Logs an error message with a tip on how to solve it.
    void
    Finishes a logging process by making some logged entries definitive.
    void
    Used to "forget" about a previous error, in case it is desirable to take into account multiple errors.
     
    int
    Like setLine(int), is only used for the purposes of the trigger loading priority system.
    boolean
     
    void
    info(String message)
    Logs an info message
    boolean
     
    void
    Advances in the currently analysed file.
    void
    Increments the recursion of the logger ; should be called before calling methods that may use SkriptLogger later in execution.
    void
    Updates the error context, which matters for establishing which errors are the most important
    void
    setDebug(boolean debug)
    Set whether this logger will print debug messages
    void
    setFileInfo(String fileName, List<FileElement> fileElements)
    Provides the logger information about the file it's currently parsing
    void
    setLine(int line)
    Like getLine(), is only used for the purposes of the trigger loading priority system.
    void
    warn(String message)
    Logs a warning message
    void
    warn(String message, @Nullable String tip)
    Logs a warning message

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • SkriptLogger

      public SkriptLogger(boolean debug)
    • SkriptLogger

      public SkriptLogger()
  • Method Details

    • setFileInfo

      public void setFileInfo(String fileName, List<FileElement> fileElements)
      Provides the logger information about the file it's currently parsing
      Parameters:
      fileName - the file name
      fileElements - the FileElements of the current file
    • nextLine

      public void nextLine()
      Advances in the currently analysed file. Used to properly display errors.
    • getLine

      public int getLine()
      Like setLine(int), is only used for the purposes of the trigger loading priority system.
      Returns:
      the current line
    • setLine

      public void setLine(int line)
      Like getLine(), is only used for the purposes of the trigger loading priority system.
      Parameters:
      line - the new line number
    • recurse

      public void recurse()
      Increments the recursion of the logger ; should be called before calling methods that may use SkriptLogger later in execution.
    • callback

      public void callback()
      Decrements the recursion of the logger ; should be called after calling methods that may use SkriptLogger later in execution.
    • setContext

      public void setContext(ErrorContext context)
      Updates the error context, which matters for establishing which errors are the most important
      Parameters:
      context - the new error context
    • error

      public void error(String message, ErrorType errorType)
      Logs an error message
      Parameters:
      message - the error message
      errorType - the error type
    • error

      public void error(String message, ErrorType errorType, @Nullable @Nullable String tip)
      Logs an error message with a tip on how to solve it.
      Parameters:
      message - the error message
      errorType - the error type
      tip - the tip for solving the error
    • warn

      public void warn(String message)
      Logs a warning message
      Parameters:
      message - the warning message
    • warn

      public void warn(String message, @Nullable @Nullable String tip)
      Logs a warning message
      Parameters:
      message - the warning message
      tip - the tip for solving the warning
    • info

      public void info(String message)
      Logs an info message
      Parameters:
      message - the info message
    • debug

      public void debug(String message)
      Logs a debug message. Will only work if debug mode is enabled.
      Parameters:
      message - the debug message
    • forgetError

      public void forgetError()
      Used to "forget" about a previous error, in case it is desirable to take into account multiple errors. Should only be called by the parser.
    • clearNotError

      public void clearNotError()
      Clears every log that is not an error or a debug message.
    • clearErrors

      public void clearErrors()
      Clears every log that is an error message.
    • clearLogs

      public void clearLogs()
      Clears every log that is not a debug message.
    • finalizeLogs

      public void finalizeLogs()
      Finishes a logging process by making some logged entries definitive. All non-error logs are made definitive and only the error that has the most priority is made definitive.
    • close

      public List<LogEntry> close()
      Finishes this Logger object, making it impossible to edit.
      Returns:
      the final logged entries
    • isDebug

      public boolean isDebug()
      Returns:
      whether this Logger is in debug mode
    • setDebug

      public void setDebug(boolean debug)
      Set whether this logger will print debug messages
      Parameters:
      debug - Whether to enable debug mode
    • getFileName

      public String getFileName()
    • hasError

      public boolean hasError()
      Returns:
      whether or not this Logger has an error stored