Reading console output

Discussion in 'Plugin Development' started by ferrybig, Dec 16, 2013.

?

Do you want this feacture back

  1. Yes, I want the feature back to read the console from my plugin

    54.5%
  2. Yes, I want this to come back, and I didn't know it was inside bukkit

    45.5%
  3. No, I don't want this feature to come back because I don't use it

    0 vote(s)
    0.0%
  4. No, I don't want this feature to come back because I think remote console plugins are useless

    0 vote(s)
    0.0%
  5. No, I don't want this feature back because I don't use it

    0 vote(s)
    0.0%
Thread Status:
Not open for further replies.
  1. Hello guys,

    Inside minecraft version 1.6.4 and earlier, there was a method to read the console, using
    Code:java
    1.  
    2. Bukkit.getLogger().addHandler(new Handler(){
    3. @Override
    4. public synchronized void publish(LogRecord record)
    5. {
    6. /* ... */
    7. }
    8. public synchronized void flush()
    9. {}
    10.  
    11. public synchronized void close() throws SecurityException
    12. {
    13. /* ... */
    14. }

    This method doesn't work since 1.7.2 anymore, breaking features of at least 2 of my plugins, Multiworld(monitoring the world load process) and Adesk Mc Console (remote console monitoring)

    Are there any replacements for this trick? It worked since bukkit was created and is really annoying to lose the method to read the console after so long.

    Thx for you help.
     
  2. Offline

    RawCode

    you can hook on System.out stream without any API, there is nothing that can stop from doing this, this allows to read raw console output excluding JVM verbose.
     
  3. Any examples how to catch the console output using this trick, a printstream object contains many methods, what methode must I override to catch the output? with the console reading using logger, I only needed to override the publish methode

    EDIT: using this trick I won't be able to see if a message if either warning or info (or a other level) and I wont get the other information that the java lggers give me.
     
  4. Offline

    1Rogue

    Why can't you add a handler to the logger? It works fine for me...
     
  5. Offline

    The_Doctor_123

    You could hijack the out and err PrintStreams. So, capture the current references, then set the out and err streams to a new PrintStream and override all the methods. When overriding, call the superclass method and the method from the old stream. That should give you all console output, I believe. You could also hijack the in InputStream as well, if needed.
     
  6. Offline

    RawCode

    just set out stream to your own stream with methods you like, JVM will have access to that object anyway.

    when setting object use sync block or halt thread, it may fail if other thread will attempt to use stream at same time.

    in most cases you will need to change println method only.
     
  7. I tested it before posting here, you can only capture the things plugins say using this trick, not the output from minecraft and the commands
    you can't create a printstream easy that pas al its arguments to its parents streams
    because the bukkit library doesn't say what methods it use at the outputstream and the error stream, we must override them al, because else there will be possible problems in the future, also, doing it this way is at least 300 lines of codes to make it work, where the other way was lower than 50, bukkit should fix the methode to recieve the log
     
  8. Offline

    The_Doctor_123

    ferrybig
    Decently sure you can since I've done it.
     
  9. Offline

    nickgs1337

    how i read the console output on 1.7.2?
     
Thread Status:
Not open for further replies.

Share This Page