From 486630efc70804c4b44e1d80a0abf67247970a20 Mon Sep 17 00:00:00 2001 From: Michel Donais Date: Thu, 24 Dec 2020 10:13:09 -0500 Subject: [PATCH] OSS-68 Adding Logger to MisoGlobalInfo --- README.md | 3 +++ .../Logger+bundleIdentifier.swift | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 Sources/MisoGlobalInfo/Logger+bundleIdentifier.swift diff --git a/README.md b/README.md index e5fe967..e2d7f05 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,9 @@ Instead of searching everywhere for the most used variables, these are provided - App store receipt retrieval: `GlobalInfo.App.appStoreReceiptURL`, `GlobalInfo.App.hasAppStoreReceipt` and `GlobalInfo.App.appStoreReceipt` - identifierForVendor's UUID retrieval (not for advertisements): `GlobalInfo.OS.uuid` +### macOS 11 / iOS 14 Logger support + +- Defines the `subsystem` as the `bundleIdentifier` automatically. Simply create your logger with the category: `Logger(category: "SomeCategory")` ## Colophon diff --git a/Sources/MisoGlobalInfo/Logger+bundleIdentifier.swift b/Sources/MisoGlobalInfo/Logger+bundleIdentifier.swift new file mode 100644 index 0000000..c852ac8 --- /dev/null +++ b/Sources/MisoGlobalInfo/Logger+bundleIdentifier.swift @@ -0,0 +1,19 @@ +// +// MisoGlobalInfo.swift +// MisoGlobalInfo +// +// Created by Michel Donais on 2020-12-24. +// Copyright © 2019-2020 Misoservices Inc. All rights reserved. +// [BSL-1.0] This package is Licensed under the Boost Software License - Version 1.0 +// + + +import os + +@available(macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0, *) +public extension Logger { + init(category: String) { + self.init(subsystem: GlobalInfo.App.bundleIdentifier ?? "No bundleIdentifier", + category: category) + } +}