Colors in log files

Discussion in 'Plugin Development' started by Gildan27, Dec 21, 2012.

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

    Gildan27

    I have been unable to determine how colors end up in log files. I'd like to put colors on my plugin's output in the log file. Does anyone know how to do this? ChatColor.Red puts:
    2012-12-21 20:33:33 [INFO] [MyPlugin] §cHello world
    ...which is not what I want, obviously. This is what I'm talking about:

    [​IMG]

    Anyone know how to do it?
     
  2. Offline

    LaxWasHere

    Offtopic: Why bother, most servers have the colours disabled anyways. Also why are you running the server as r007.
     
  3. Offline

    Gildan27

    It's a server we built to run a private CraftBukkit server, so we control it completely. It is very unlikely that the plugin I'm developing will ever run on any server except this one. The Minecraft server itself is running as a different user via a Linux init script; I'm just logged into the server as root, and viewing the log via Linux's "tail -f"

    Anyway, after some amount of digging, I have found that one can use the following to produce colors in the log file:
    Code:
    int red = 1;
    int green = 2;
    int yellow = 3;
    int purple = 4;
    int pink = 5;
    int teal = 6;
    plugin.getLogger().info("\u001B[3" + red + ";1m" + "This text is red" + "\u001B[m");
    From here, it's pretty straightforward to write a wrapper class to do this. I do still wonder, though, if Bukkit has a built-in way to do this, although I'm inclined to think not, as this is specific to Putty, and thus would not work on Windows.
     
Thread Status:
Not open for further replies.

Share This Page