fpillet / NSLogger

A modern, flexible logging tool
Other
5k stars 573 forks source link

Trouble loading from buffered file #275

Closed subdigital closed 5 years ago

subdigital commented 5 years ago

I'm evaluating NSLogger for saving logs in production (os_log is great but it's really cumbersome to retrieve logs in the wild)

In a demo app I have this code:

        LoggerSetBufferFile(nil, "/Users/ben/Desktop/demo.nsloggerdata" as CFString)
        LoggerSetOptions(nil, UInt32(kLoggerOption_BufferLogsUntilConnection))

        Logger.shared.log(.app, .debug, "Some debug logs")
        Logger.shared.log(.app, .warning, "Some warning logs")

        for _ in 0...235 {
            Logger.shared.log(.service, .info, "Some info logs")
        }

If I close the NSLogger Mac app, I do see a file, and it grows in size, however when I try to open this file I get this error:

screen shot 2019-01-18 at 12 14 06 pm

I looked around for examples and all I've seen is code similar to the above. What am I doing wrong here?

fpillet commented 5 years ago

You're not doing anything wrong, Ben. When I converted the code to ARC recently, I broke a couple things and loading buffered file was the last one left unnoticed. Master has the required changes (if you launch the viewer from Xcode it will work), I'll push a new binary build of the viewer in the coming days.

Let me know if you want a build now, I have one I can email.

subdigital commented 5 years ago

👋 @fpillet ;)

I can run off master for now, thanks for the lightning quick reply!

subdigital commented 5 years ago

Looks like I also needed to use rawnsloggerdata as the file extension as well. What's the difference?

fpillet commented 5 years ago

Raw files are just brutal storage of what goes over the wire (it's a binary format close to protobuf).

Saves from the desktop app are logs read from the wire, then later serialized with NSCoder. Hence the need for a separate extension :)