Skip to content

Releases: apple/swift-log

1.6.2

26 Nov 15:32
96a2f8a
Compare
Choose a tag to compare

What's Changed

SemVer Patch

Other Changes

New Contributors

Full Changelog: 1.6.1...1.6.2

Swift Log 1.6.1

24 Jun 17:37
9cb4860
Compare
Choose a tag to compare

SemVer Patch

  • Disable existential any build setting (#312)

1.6.0

24 Jun 08:27
b3a6373
Compare
Choose a tag to compare

SemVer Minor

  • Add Sendability annotations in #308
  • Fix deprecation warnings around default log implementations on handlers in #310
  • Drop Swift versions earlier than 5.8 in #299
  • Implement Copy-On-Write (CoW) behavior for Logger struct by @ayushi2103 in #297

SemVer Patch

  • Replace standardOutput to standardError by @ayushi2103 in #295
  • Use Set to spot duplicated log handler warnings in #306
  • Make protocol usage obvious using any and some keywords in #307
  • Remove documentation for non-existent arguments by @b1ackturtle in #309
  • Remove Docc plugin which is no longer required in #311

Other Changes

  • Remove archived repository in #292
  • Add CI for Swift 5.10 in #287
  • Added swift-log-ecs to README.md by @rwbutler in #298
  • Update README.md add shipbook as backend by @elishas in #304

1.5.4

22 Jan 10:50
1.5.4
e97a6fc
Compare
Choose a tag to compare

What's Changed

Cleanups & minor compatibility improvements

Non code changes

New Contributors

Full Changelog: 1.5.3...1.5.4

1.5.3

11 Aug 06:52
1.5.3
532d8b5
Compare
Choose a tag to compare

What's Changed

Cleanups & minor compatibility improvements

Non code changes

New Contributors

Full Changelog: 1.5.2...1.5.3

1.5.2

24 Jan 01:50
1.5.2
32e8d72
Compare
Choose a tag to compare

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

  • Avoid logging warnings when handler does not support metadataproviders by @ktoso in #252
  • Handle providers properly in multiplex log handler by @ktoso in #254
  • Add CI for Swift 5.8 and update nightly to Ubuntu 22.04 by @yim-lee in #255

Full Changelog: 1.5.1...1.5.2

1.5.1

19 Jan 10:42
1.5.1
3e3ef75
Compare
Choose a tag to compare

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

  • Allow passing explicit provider into the stream handlers by @ktoso in #250
  • Emit correct metadata from StreamLogHandler by @slashmo in #251

Full Changelog: 1.5.0...1.5.1

1.5.0

18 Jan 07:42
1.5.0
e6ca651
Compare
Choose a tag to compare

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

  • Metadata Providers (e.g. for Distributed Tracing) in LogHandlers by @ktoso in #238

Other changes

  • [docs] Minimal docc setup and landing page by @ktoso in #226
  • =docc Make docs use symbol references by @ktoso in #230
  • =docc Move to multiple Package.swift files by @ktoso in #231
  • Undo 5.7 package files, not needed yet by @ktoso in #232
  • Update README: Add missing Source param by @rusik in #233
  • Fix build for wasm by @ahti in #236
  • Add .spi.yml for Swift Package Index DocC support by @yim-lee in #240
  • Fixes link to Supabase repository in README.md by @timobollwerk in #245

New Contributors

Full Changelog: 1.4.4...1.5.0

1.4.4

15 Aug 07:44
1.4.4
Compare
Choose a tag to compare

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

  • [sendable] Sendable conformance checks cause errors on 5.6 but warnings on 5.7 by @ktoso in #229

Full Changelog: 1.4.3...1.4.4

1.4.3

10 Aug 08:46
1.4.3
8fc79ca
Compare
Choose a tag to compare

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: #218

What's Changed

New Contributors

Full Changelog: 1.4.2...1.4.3