Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! C:\Python27\python.exe
- # Imports
- import os
- import re
- import sys
- # Configuration
- #show_everything = True
- show_everything = False
- #logFilePath = 'C:/Users/' + os.getenv('username') + '/Documents/My Games/Binding of Isaac Rebirth/log.txt'
- #logFilePath = 'C:/Users/' + os.getenv('username') + '/Documents/My Games/Binding of Isaac Afterbirth/log.txt'
- logFilePath = 'C:/Users/' + os.getenv('username') + '/Documents/My Games/Binding of Isaac Afterbirth+/log.txt'
- fileArrayPosition = 0
- def main():
- while True:
- parseLog()
- def parseLog():
- global fileArrayPosition
- # Read the log into a variable
- try:
- with open(logFilePath, 'r') as f:
- fileContents = f.read()
- except Exception:
- print('I could not open the log file at "' + logFilePath + '".')
- sys.exit(1)
- # Convert it to an array
- fileArray = fileContents.splitlines()
- # Return to the start if we go past the end of the file (which occurs when the log file is truncated)
- if fileArrayPosition > len(fileArray):
- fileArrayPosition = 0
- # Process the log's new output
- for line in fileArray[fileArrayPosition:]:
- # Show everything for debugging purposes
- if show_everything:
- print(line)
- # Show errors and Lua debugging messages
- if show_everything == False:
- if line.startswith('[INFO] - ERR'):
- print(line)
- elif line.startswith('[INFO] - Lua Debug: '):
- print(line)
- elif "Error" in line or "error" in line or "ERROR" in line:
- print(line)
- elif "Warn" in line or "warn" in line or "WARN" in line:
- print(line)
- elif "Fail" in line:
- print(line)
- # Set that we have read the log up to this point
- fileArrayPosition = len(fileArray)
- # The main program
- if __name__ == '__main__':
- main()
Add Comment
Please, Sign In to add comment