Debug function

TailsLib providing Debug methods to log important data.

Setup

First of all look to the config and enable debug, console logging, make comfort debug format for you and rename all prefixes if needed.

Debug section in config:

debug:
  enabled: no

  # %class% - Basicly file name
  # %method% - Method that called debug function
  # %line% - Line in code
  # %reciever% - Player that recieve this debug msg. "none" if player is null
  format: "[%class%:%method% at %line%] [To: %reciever%] %msg%"

  # Log to console?
  console: yes

  #TailsLib will stop reporting errors that may break the server or plugin errors.
  #By default, TailsLib will send error messages to the player even if debug.enabled is turned off.
  supressErrors: no

  # Prefix for debug.
  prefix: "&r[%s&r]"
  info: "INFO"
  warn: "&eWARN"
  error: "&cERROR"

Using Debug

Debug methods are all static. They are using stack trace information and providing it to the logs.

You can also send message to player with that debug message.

Usage:

@Override
public void rightClick(PlayerInteractEvent event, UUID uuid) {
    Debug.info("Only log to console");
    Debug.warn("You got the debug message!", event.getPlayer());
    Player offlinePlayer = Bukkit.getPlayer("OfflineGuy134"); // null
    Debug.error("Sends to console only if player is null", offlinePlayer);
}

Why should i use it?

You can forget about logging thing into server console or forget about removing those debug messages from code. Just turn off debug messages in TailsLib config.

Also if you don't want to receive debug messages you can use /tlib debug false to stop recieving debug messages.

Last updated

Was this helpful?