Allow specifying a callback

Made it so that you can specify a callback and you get a stacktrace in it. You can then write to the file yourself if you want or do anything else (write to the database).