Forum Archive

[Share Code] Access Pythonistas System log

lukaskollmer

Hi!

I wrote this script to access the System Log.

Usage
- Download the script
- Run it as main to view a console-like log history
- Import it and call the get_log() function to fetch the log messages for your own scripts

How it works:
- This script is calling the ASL API (Apple System Log) to fetch the latest log entries
- Please note that the log history won't be deleted every time you start the app so theres sometimes still old messages in the history
- The cool thing about still having the old logs is that, since uncaught exceptions are written to the console, you can load the console history after a crash and there's a pretty I good change of getting a crash description
- This script formats the messages to look similar to Xcodes built in console, by adding the date and time before each message
- This script only works on iOS 9, since (as of iOS 10 beta 1) Apple deprecated the ASL interface and the new API doesn't yet offer a way to get log messages

Examples:

Usual logs:

Logged exceptions:

filippocld

Nice! Very Interesting