Custom Logs API

Discussion in 'Resources' started by NoLiver92, Nov 20, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    NoLiver92

    This resource will allow you to easily add custom logs to your plugin and will also give you the option to have a server side GUI to display the current logs. Using this is simple and uses the same functions as the normal minecraft logger BUT they have been modified to allow for the GUI. The API also allows for multiple log files to be created allowing greater flexibility of what you want logged and where it is logged to.

    How To Use The API:
    1) Add the API file you your build path

    2) In plugin.yml, make a dependency (can be soft-depend) for "CustomLogAPI" (You will also need the plugin in the plugin folder on the server)
    Code:java
    1. depend: [CustomLogAPI]


    3) Call the constructor in your plugin:
    Code:java
    1. CustomLogAPI api = new CustomLogAPI(plugin, filename, boolean);

    plugin = instance of your main plugin file
    filename = the name of the log file you want (do not include the extension as the API automatically uses '.log')
    boolean = true/false to display the GUI screen (server side only)

    4) Log messages: There is two ways to log a message:
    • INFO
    • WARNING
    The format of the message in the log file follows the same format as the craftbukkit logger. Heres how to add the messages:
    Code:java
    1. api.Info("Info Message");
    2. api.Warning("Warning Message");


    5) Close the GUI: If you use the GUI this is a MUST!!! This should be placed in your "onDisable()" function to make sure that when the server restarts/closes the windows close. Otherwise you will get multiple instances of the logger.
    Code:java
    1. api.closeLogDisplay();

    This is recommended BUT depending on your plugin it may not be needed.

    Download Location: BukkitDev

    I am willing to expand this plugin/API to add features which people request. So if you have an idea you would like to be added in, add it to the end of this post.
     
  2. Offline

    Ultimate_n00b

    NoLiver92 One thing you should probably do, is explain why we should use this instead of a different logger. As we can already do all of these things through the Bukkit object.
    Code:
    Logger log = Bukkit.getLogger();
    log.info("Info");
    log.warning("Warning");
    log.severe("Severe");
     
  3. Offline

    NoLiver92

    Did you actually read the post?

    This API will create a GUI screen (like another console) which shows the current messages logged, this means you dont have to open/refresh the file every time you want to look at it.

    It also allows for the user to make multiple log files with minimal code. For Example you could want 4 different log files, 1 for each arena) This API will allow you to easily create these log files as it is easy to use
     
  4. Offline

    user_43347

    Or, you know. The only thing the Java logger doesn't have would be the GUI.
     
    Ultimate_n00b likes this.
Thread Status:
Not open for further replies.

Share This Page