Skip to content

Releases: 0xLeif/Scribe

2.0.2

29 Mar 23:54
Compare
Choose a tag to compare

Full Changelog: 2.0.1...2.0.2

2.0.1

29 Mar 23:44
Compare
Choose a tag to compare

Full Changelog: 2.0.0...2.0.1

2.0.0

29 Mar 23:38
8abf60e
Compare
Choose a tag to compare

What's Changed

Full Changelog: 1.3.2...2.0.0

1.3.2

10 Mar 15:40
Compare
Choose a tag to compare

Full Changelog: 1.3.1...1.3.2

1.3.1

10 Mar 15:37
Compare
Choose a tag to compare

Full Changelog: 1.3.0...1.3.1

1.3.0

18 Feb 02:34
7988180
Compare
Choose a tag to compare

What's Changed

  • Update Plugin to 2.0.0 for Fork async by @0xLeif in #7

Full Changelog: 1.2.0...1.3.0

1.2.0

10 Feb 03:38
60bfb95
Compare
Choose a tag to compare

What's Changed

  • Update o package and allow for path in FilePlugin by @0xLeif in #5
  • Add other init methods for Scribe Logger by @0xLeif in #6

Full Changelog: 1.1.0...1.2.0

1.1.0

02 Feb 01:47
8b252d8
Compare
Choose a tag to compare

What's Changed

Full Changelog: 1.0.0...1.1.0

1.0.0

02 Feb 01:02
5ede594
Compare
Choose a tag to compare

What's Changed

Full Changelog: 0.1.1...1.0.0

0.1.1

31 Jan 04:15
281be93
Compare
Choose a tag to compare

What's Changed

  • Update Plugin version and lower platform versions by @0xLeif in #2

Full Changelog: 0.1.0...0.1.1


Scribe

📜 Logging all events

Scribe is a flexible logging library for Swift, designed to make logging easy and efficient. It provides a centralized system for logging messages and events within your application, and supports multiple logging outputs and plugins to extend its capabilities to meet your needs. Scribe integrates with swift-log for console logging, making it a versatile solution for all your logging requirements.

Usage

Creating a ScribePlugin

To create a Scribe plugin, you need to create a struct or class that conforms to the ScribePlugin protocol and implement its requirements. Here is an example of a simple plugin that increments a count for each log:

class CountPlugin: ScribePlugin {
    static let shared = CountPlugin()

    var count: Int = 0

    private init() {}

    func handle(value: Scribe.PluginPayload, output: inout ()) async throws {
        count += 1
    }
}

Registering plugins to Scribe

Once you have created your Scribe Plugin, you just need to register it with your Scribe object. There are two ways to do this:

  1. Pass the plugin to the plugins parameter when creating the Scribe object:
let scribe = Scribe(
    label: "test.count",
    plugins: [
        CountPlugin.shared
    ]
)
  1. Call scribe.register(plugin:) to add the plugin to an existing Scribe object:
let scribe = Scribe(label: "test.count")

scribe.register(plugin: CountPlugin.shared)

Logging to Scribe

Scribe uses swift-log for logging, so the functions are similar in usage. To log a message with Scribe, simply call one of the logging functions, such as debug:

scribe.debug("Test")

Log Levels

Scribe supports the following log levels:

  • trace
  • debug
  • info
  • notice
  • warning
  • error
  • critical

Choose the appropriate log level depending on the importance and urgency of the message you are logging.