Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This Python script makes one pass through a logfile read from stdin, printing the filtered log messages to stdout.</p> <p>It uses a regular expression to match lines that mark the beginning of a log message (such as a line that starts with <code>2011-03-02 01:43:00 [</code>).</p> <p>If a line that begins a log message contains <code>[SEVERE] Could not pass event REDSTONE_CHANGE to CraftBookMechanisms</code>, the script discards all lines between that line and the line containing the start of the next log message. Otherwise, it outputs the line. You can think of this as a finite state machine with two states, which correspond to whether the script is skipping over lines or outputting lines.</p> <pre><code>import sys import re START_OF_MESSAGE_RE = r"^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}" ERROR_RE = START_OF_MESSAGE_RE + r' \[SEVERE\] Could not pass event REDSTONE_CHANGE to CraftBookMechanisms$' skip_until_next_message = False for line in sys.stdin: line = line.rstrip() if re.match(START_OF_MESSAGE_RE, line): if re.match(ERROR_RE, line): skip_until_next_message = True else: skip_until_next_message = False if not skip_until_next_message: print line </code></pre> <p>I added some special cases to the log file for testing. Here's the log file that I tested it with:</p> <pre><code>2011-03-02 01:43:00 [INFO] &lt;admin&gt; CraftBook is causing errors. 2011-03-02 01:43:01 [SEVERE] Could not pass event REDSTONE_CHANGE to CraftBookMechanisms java.lang.NoSuchMethodError: com.sk89q.worldedit.blocks.BlockType.isRedstoneBlock(I)Z at com.sk89q.craftbook.bukkit.MechanicListenerAdapter$MechanicBlockListener.onBlockRedstoneChange(MechanicListenerAdapter.java:174) at net.minecraft.server.BlockButton.a(BlockButton.java:170) at net.minecraft.server.ItemInWorldManager.a(ItemInWorldManager.java:160) at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:482) at net.minecraft.server.Packet15Place.a(SourceFile:57) at net.minecraft.server.NetworkManager.a(SourceFile:230) at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:75) at net.minecraft.server.NetworkListenThread.a(SourceFile:100) [SEVERE] Could not pass event REDSTONE_CHANGE to CraftBookMechanisms at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:357) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:272) at net.minecraft.server.ThreadServerApplication.run(SourceFile:366) 2011-03-02 01:43:01 [INFO] &lt;admin&gt; Is it working yet? 2011-03-02 01:43:01 [INFO] &lt;admin&gt; Not really. 2011-03-02 01:43:01 [SEVERE] Could not pass event REDSTONE_CHANGE to CraftBookMechanisms java.lang.NoSuchMethodError: com.sk89q.worldedit.blocks.BlockType.isRedstoneBlock(I)Z at com.sk89q.craftbook.bukkit.MechanicListenerAdapter$MechanicBlockListener.onBlockRedstoneChange(MechanicListenerAdapter.java:174) at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:348) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:272) at net.minecraft.server.ThreadServerApplication.run(SourceFile:366) 2011-03-02 01:43:02 [INFO] &lt;admin&gt; I hope we find a solution as soon as ever possible. 2011-03-02 01:43:01 [SEVERE] Another multi line log message 2011-03-02 01:43:01 [INFO] &lt;admin&gt; Here's the error: [SEVERE] Could not pass event REDSTONE_CHANGE to CraftBookMechanisms </code></pre> <p>And here's the output:</p> <pre><code>$ python minecraftlog.py &lt; minecraft.log 2011-03-02 01:43:00 [INFO] &lt;admin&gt; CraftBook is causing errors. 2011-03-02 01:43:01 [INFO] &lt;admin&gt; Is it working yet? 2011-03-02 01:43:01 [INFO] &lt;admin&gt; Not really. 2011-03-02 01:43:02 [INFO] &lt;admin&gt; I hope we find a solution as soon as ever possible. 2011-03-02 01:43:01 [SEVERE] Another multi line log message 2011-03-02 01:43:01 [INFO] &lt;admin&gt; Here's the error: [SEVERE] Could not pass event REDSTONE_CHANGE to CraftBookMechanisms </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload