{"id":6152,"library":"pyobjc-framework-oslog","title":"PyObjC OSLog Framework Wrappers","description":"PyObjC-framework-OSLog provides Python wrappers for Apple's OSLog framework on macOS, allowing Python applications to interact with the unified logging system. It is part of the larger PyObjC project, currently at version 12.1, and maintains an active release cadence with frequent updates to align with macOS SDK changes and Python versions.","status":"active","version":"12.1","language":"en","source_language":"en","source_url":"https://github.com/ronaldoussoren/pyobjc","tags":["macos","objective-c","logging","framework","pyobjc"],"install":[{"cmd":"pip install pyobjc-framework-oslog","lang":"bash","label":"Install OSLog wrappers"}],"dependencies":[{"reason":"Required core bridge for all PyObjC framework wrappers.","package":"pyobjc-core"},{"reason":"Requires Python 3.10 or later.","package":"python","optional":false}],"imports":[{"note":"The framework's functionality is exposed directly under the 'OSLog' module name.","symbol":"OSLog","correct":"import OSLog"},{"note":"Functions are typically available directly within the imported OSLog module.","symbol":"OSLog.os_log_create","correct":"from OSLog import os_log_create"}],"quickstart":{"code":"import OSLog\nfrom Foundation import NSObject\n\ndef main():\n    # Instantiate an OSLog object (equivalent to Objective-C: [[OSLog alloc] initWithSubsystem:category:])\n    # os_log_create is an alternative to OSLog.alloc().init...\n    log_handle = OSLog.os_log_create('com.example.myapp', 'general')\n\n    # Log a message at the default level (OS_LOG_TYPE_DEFAULT)\n    # Equivalent to Objective-C: os_log(log_handle, \"Hello from PyObjC OSLog!\");\n    # Note: For simplicity, string formatting and privacy modifiers (%{public}s, %{private}s) are not shown here\n    # as they typically apply to C-level os_log calls. PyObjC handles basic strings directly.\n    OSLog.os_log_with_type(log_handle, OSLog.OS_LOG_TYPE_DEFAULT, 'Hello from PyObjC OSLog!')\n    print('Logged a message to system console. Check Console.app for \"Hello from PyObjC OSLog!\".')\n\nif __name__ == '__main__':\n    main()","lang":"python","description":"This quickstart demonstrates how to import the OSLog framework and log a simple message to the macOS unified logging system. It shows how to create a log handle and then use `os_log_with_type` to send a message. You can view these logs using macOS's Console.app."},"warnings":[{"fix":"Ensure your Python environment is 3.10 or later. Upgrade Python if necessary.","message":"PyObjC 12.x (including pyobjc-framework-oslog 12.1) officially drops support for Python 3.9. PyObjC 11.x dropped support for Python 3.8.","severity":"breaking","affected_versions":"11.0, 12.0+"},{"fix":"Review Objective-C object initialization patterns in your PyObjC code, especially those involving `alloc().init...()`. Ensure correct reference handling, as PyObjC now more strictly enforces ARC semantics.","message":"PyObjC 11.1 introduced significant changes to align the core bridge's Automatic Reference Counting (ARC) behavior with `clang`'s documentation for initializer methods. Methods in the 'init' family now correctly steal and return new references. Code that accidentally worked in previous versions due to hidden reference counting bugs may now crash.","severity":"breaking","affected_versions":"11.1+"},{"fix":"Avoid using `__init__` in conjunction with the default `__new__` provided by PyObjC for Objective-C classes. If you need custom initialization logic, consider using Objective-C compatible initializer methods (e.g., `initWith...`).","message":"There was a breaking change in PyObjC 10.3 regarding the interaction of `__init__` and `__new__` in Python subclasses of Objective-C classes. While 10.3.1 partially reverted this, user-defined `__init__` methods on classes with a user-defined `__new__` will work, but `__init__` cannot be used with the `__new__` provided by PyObjC.","severity":"gotcha","affected_versions":"10.3 - 10.3.1"},{"fix":"Consult Apple's developer documentation for the OSLog framework and the macOS version your application targets to ensure continued API availability and best practices.","message":"PyObjC frameworks are direct wrappers of Apple's Objective-C frameworks. If Apple deprecates or removes an underlying framework (e.g., IMServicePlugIn removed in macOS 14), its PyObjC bindings will also be removed in future PyObjC versions without specific deprecation cycles within PyObjC itself.","severity":"deprecated","affected_versions":"All versions (future impact)"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z","problems":[]}