Skip to content

Log NSLogs into a file and show the log when the device is shaken.

License

Notifications You must be signed in to change notification settings

dasdom/LogStore_ObjC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LogStore

Redirect NSLog on the fly into a file and present the log in your app when you need.

Usage

Activate redirection of NSLog:

Show log:

Deactivate redirection of NSLog and delete stored log:

Indicator at the top left that redirection into file is active:

Log:

Installation:

  • Put LogStore.h and LogStore.m into you project. It's tiny. Just 268 cloc.
  • Add the following to you AppDelegate:
- (UIWindow *)window {
    if (!_window) {
        _window = [LogStore shakeableWindow];
    }
    return _window;
}
  • Remember to remove this code prior to submitting to review.

Swift

Swift does not print to stderr by default. So to redirect print() in Swift to the same file, add this code:

import Foundation

var standardError = FileHandle.standardError

extension FileHandle : TextOutputStream {
    public func write(_ string: String) {
        guard let data = string.data(using: .utf8) else { return }
        self.write(data)
    }
}

and use print("foobar", to:&standardError) instead of print("foobar").

Or you can just use NSLog("foobar") in Swift as well.

Licence

MIT

Author

Dominik Hauser

@swiftpainless

About

Log NSLogs into a file and show the log when the device is shaken.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published