$ show fpillet/NSLogger
NSLogger is a remote logging framework for Apple (iOS, macOS, tvOS) and Android platforms. It consists of client libraries (C/Objective-C Swift wrapper for Apple, Java for Android) that send structured log messages (text, binary data, images) over TCP to a desktop viewer application. The desktop viewer (macOS app) provides real-time log viewing with filtering, color coding, search, marks, export, and preference management. An iPad viewer application also exists for on-device log viewing with Core Data persistence and Bluetooth support. The codebase includes multiple Xcode projects for different targets, test apps, and vendored third-party libraries (BWToolkit, HockeySDK-Mac, SSSelectableToolbar). While functional and well-known (4.9k stars), the project shows significant age: manual memory management (non-ARC), duplicated viewer logic across Desktop and iPad, incomplete features (JSON message format stubbed), outdated dependencies, and deprecated API usage. It remains a valuable reference for implementing a custom binary logging protocol and network transport layer, but would require modernization for current platform versions.
The LLM identified 3 files worth highlighting for reuse:
The core C client implementation of NSLogger. It provides functions to initialize a logger, start a background worker thread, discover the viewer via Bonjour (NSNetServiceBrowser) or connect to a direct host, and send log messages over TCP. It uses a growable message queue protected by mutex and condition variable for thread-safe enqueue/dequeue. Supports buffering to a file when no network is available (auto-replay on reconnect). Handles sending structured binary messages (text, data, images) with metadata (timestamps, thread IDs, tags, levels). Also captures stdout/stderr via pipe redirection and forwards as log messages. This is a self-contained library that can be extracted and reused in any iOS/macOS project requiring remote logging.
The TCP transport for the macOS desktop viewer. It publishes a Bonjour service to advertise the viewer's presence, listens for incoming TCP connections (with optional SSL), and manages connected clients. For each connection, it creates a LoggerTCPConnection instance that handles the protocol. Uses CFSocket for listening and CFReadStream/CFWriteStream for I/O. Implements SSL certificate settings via CFStream properties. Designed as a reusable network listener component that can be adapted for other server-side applications needing Bonjour discovery and SSL.
A small but practical Objective-C category on NSManagedObjectContext that provides convenience methods for fetching managed objects: fetchEntityName:withPredicate:, fetchEntityName:withPredicate:sortDescriptors:limit:, fetchEntityName:withPredicate:sortDescriptors:limit:resultType:, and countEntityName:withPredicate:. Each method handles errors internally (logs to console) and returns nil/0 on failure. This is a clean, reusable utility that can be extracted into any Core Data project to reduce boilerplate fetch code.