Swift Log Versions Save

A Logging API for Swift

1.5.4

3 months ago

What's Changed

Cleanups & minor compatibility improvements

Non code changes

New Contributors

Full Changelog: https://github.com/apple/swift-log/compare/1.5.3...1.5.4

1.5.3

8 months ago

What's Changed

Cleanups & minor compatibility improvements

Non code changes

New Contributors

Full Changelog: https://github.com/apple/swift-log/compare/1.5.2...1.5.3

1.5.2

1 year ago

Primary change

Address too aggressive warning logging on LogHandlers that do not support MetadataProvider. The warning would be emitted too frequently, resulting in flooding logs with warnings. Instead, the warning is now emitted once per log handler type.

What's Changed

Full Changelog: https://github.com/apple/swift-log/compare/1.5.1...1.5.2

1.5.1

1 year ago

Summary

This patch release focuses on minor cleanups to ergonomics of setting metadata providers with the default stream log handlers, and fixes a bug in the default handler not printing the provided extra metadata by default (it does now).

Thank you to @slashmo for quickly noticing and providing a patch for the latter!

What's Changed

Full Changelog: https://github.com/apple/swift-log/compare/1.5.0...1.5.1

1.5.0

1 year ago

Changes

Swift version support

This release drops support for Swift 5.0.

Swift 5.1+ remain supported for the time being.

Logger.MetadataProvider

This release introduces metadata providers!

They are an additional way to add metadata to your log statements automatically whenever a log statement is about to be made. This works extremely well with systems like distributed tracing, that may pick up trace identifiers and other information from the task-local context from where the log statement is being made.

The feature came with a swift evolution style proposal introduction to the "why?" and "how?" of this feature you may find interesting.

Metadata providers are used like this:

import Logging

enum Namespace { 
  @TaskLocal static var simpleTraceID: String?
}

let simpleTraceIDMetadataProvider = Logger.MetadataProvider { 
    guard let traceID = Namespace.simpleTraceID else {
        return [:]
    }
    return ["simple-trace-id": .string(traceID)]
 }

LoggingSystem.bootstrap({ label, metadataProvider in
    myCoolLogHandler(label: label, metadataProvider: metadataProvider)
}, metadataProvider: simpleTraceIDMetadataProvider)

which in turn makes every Logger on this LoggingSystem add this contextual metadata to log statements automatically:

let log = Logger(label: "hello")

Namespace.$simpleTraceID.withValue("1234-5678") {
  test()
}

func test() {
  log.info("test log statement")
}

// [info] [simple-trace-id: 1234-5678] test log statement

Adoption in LogHandlers

In order to support this new feature in your log handlers, please make it accept a MetadataProvider? at creation, and store it as:

struct MyHandler: LogHandler {
    // ... 
    public var metadataProvider: Logger.MetadataProvider?
    // ...
}

What's Changed

Highlight

Other changes

New Contributors

Full Changelog: https://github.com/apple/swift-log/compare/1.4.4...1.5.0

1.4.4

1 year ago

Sendable fixup for 1.4.3

The 1.4.3 release carefully introduced Sendable across the library; sadly we missed that 5.6.x Swift series treat a "missing marker protocol conformance for Sendable" as an error while it is intended to be a warning as which it is correctly reported in Swift 5.7.

This release fixes this by not requiring that values stored in Logger.MetadataValue.stringConvertible must be Sendable, however practically speaking they should be thread-safe in any case, as it is not guaranteed in any way when/where this string convertible value will be invoked from.

This release contains no other changes from 1.4.3.

What's Changed

Full Changelog: https://github.com/apple/swift-log/compare/1.4.3...1.4.4

1.4.3

1 year ago

Highlights

Loggers and all related types are now Sendable, including metadata values which have to be Sendable as well.

When using from Swift that is concurrency aware, you may be getting warnings where you didn't before, these are all correct though - you need to be ready for e.g. logger metadata to be accessed from another thread. Thankfully values logged this way should usually be sendable to begin with, preferably value types.

For more details see: https://github.com/apple/swift-log/pull/218

What's Changed

New Contributors

Full Changelog: https://github.com/apple/swift-log/compare/1.4.2...1.4.3

1.4.2

3 years ago

This release fixes a single bug in the propagation of the function parameter in the source-less Logger.trace function.

For more details refer to https://github.com/apple/swift-log/pull/185 - thank you noticing and fixing the issue @saulbaro!

You can find additional details on all changes in this release in the 1.4.2 milestone.

1.4.1

3 years ago

This patch release fixes some compatibility issues, including a Windows compatibility issue as well as wrongly removed APIs in the 1.3.0->1.4.0 transition.

No new features were added in this release.

You can refer to the detailed changes by inspecting the issues linked form the 1.4.1 milestone.

1.4.0

3 years ago

Highlights

This release addresses a missing public init in the newly introduced NoOpLogHandler. Please use 1.4.0 rather than 1.3.0 to be able to actually instantiate the that handler.

SemVer Minor

Credits

This release contains a single PR: https://github.com/apple/swift-log/pull/146

The complete change-list is available on the 1.4.0 milestone.

Thank you @adam-fowler for spotting and fixing the mistake!