mirror of
https://github.com/apple/swift-log
synced 2026-11-24 03:47:49 +00:00
Add an InMemoryLogHandler ### Motivation: Library maintainers should be able to test that their libraries log what they expect ### Modifications: Create a new InMemoryLogging product, which contains an InMemoryLogHandler This log handler can be used to make a logger, pass the logger into some function, and then assert that logs were emitted. See the tests for example usage ### Future: For now i have left this very bare-bones. We could in future add convenience functions. For example - a function to assert that a particular log message was logged - a static function to create a logger with this handler --------- Co-authored-by: Franz Busch <privat@franz-busch.de>
65 lines
2.0 KiB
Swift
65 lines
2.0 KiB
Swift
// swift-tools-version:6.0
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This source file is part of the Swift Logging API open source project
|
|
//
|
|
// Copyright (c) 2018-2019 Apple Inc. and the Swift Logging API project authors
|
|
// Licensed under Apache License v2.0
|
|
//
|
|
// See LICENSE.txt for license information
|
|
// See CONTRIBUTORS.txt for the list of Swift Logging API project authors
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
import PackageDescription
|
|
|
|
let package = Package(
|
|
name: "swift-log",
|
|
products: [
|
|
.library(name: "Logging", targets: ["Logging"]),
|
|
.library(name: "InMemoryLogging", targets: ["InMemoryLogging"]),
|
|
],
|
|
targets: [
|
|
.target(
|
|
name: "Logging",
|
|
dependencies: []
|
|
),
|
|
.target(
|
|
name: "InMemoryLogging",
|
|
dependencies: ["Logging"]
|
|
),
|
|
.testTarget(
|
|
name: "LoggingTests",
|
|
dependencies: ["Logging"]
|
|
),
|
|
.testTarget(
|
|
name: "InMemoryLoggingTests",
|
|
dependencies: ["InMemoryLogging", "Logging"]
|
|
),
|
|
]
|
|
)
|
|
|
|
for target in package.targets {
|
|
var settings = target.swiftSettings ?? []
|
|
settings.append(.enableExperimentalFeature("StrictConcurrency=complete"))
|
|
target.swiftSettings = settings
|
|
}
|
|
|
|
// --- STANDARD CROSS-REPO SETTINGS DO NOT EDIT --- //
|
|
for target in package.targets {
|
|
switch target.type {
|
|
case .regular, .test, .executable:
|
|
var settings = target.swiftSettings ?? []
|
|
// https://github.com/swiftlang/swift-evolution/blob/main/proposals/0444-member-import-visibility.md
|
|
settings.append(.enableUpcomingFeature("MemberImportVisibility"))
|
|
target.swiftSettings = settings
|
|
case .macro, .plugin, .system, .binary:
|
|
() // not applicable
|
|
@unknown default:
|
|
() // we don't know what to do here, do nothing
|
|
}
|
|
}
|
|
// --- END: STANDARD CROSS-REPO SETTINGS DO NOT EDIT --- //
|