Contents

atacan/SwiftLogExport

A generic exporter and processor framework for swift-log backends.

Features

  • Generic: Designed to be adaptable for various logging backends.
  • Buffering: Efficiently batches log entries before exporting.
  • Non-blocking Processing: Ensures your application remains responsive by handling log exporting asynchronously.
  • Graceful Shutdown: Handles in-flight log entries during application termination.

Usage

To use SwiftLogExport, you need to implement the required protocols to provide your specific log exporting logic. The package takes care of managing the log processing pipeline.

Create a struct or class that conforms to LogExporter. You'll need to implement the export(batch:) method, which receives an array of LogRecords.

LogRecord is a protocol that represents the log entry that matches your use case.

Then initialize a LoggingHandler with your BatchLogRecordProcessor, and use it to initialize a Logger.

Run the BatchLogRecordProcessor as it a Service.

Examples

Installation

Add SwiftLogExport to your Package.swift dependencies:

dependencies: [
    .package(url: "https://github.com/atacan/SwiftLogExport.git", from: "1.0.0")
]

And add it to your target's dependencies:

targets: [
    .target(
        name: "YourApp",
        dependencies: [
            .product(name: "SwiftLogExport", package: "SwiftLogExport"),
        ]),
    // ... other targets
]

Acknowledgements

  • swift-otel: The core processing and exporting logic is heavily adapted from the swift-otel project. See its LICENSE for more details.

Package Metadata

Repository: atacan/SwiftLogExport

Stars: 1

Forks: 0

Open issues: 0

Default branch: main

Primary language: swift

License: Apache-2.0

Topics: swift, swift-log, swift-openapi-generator

README: Readme.md