swift-log-supabase

0.1.0

A logging backend for apple/swift-log that sends log entries to Supabase.
binaryscraping/swift-log-supabase

What's New

v0.1.0 🚀

2022-05-10T12:44:07Z

swift-log-supabase

A logging backend for apple/swift-log that sends log entries to Supabase.

Getting Started

Add swift-log-supabase as a dependency to your project using SPM.

.package(url: "https://github.com/binaryscraping/swift-log-supabase", from: "0.1.0"),

And in your application/target, add "SupabaseLogger" to your "dependencies".

.target(
  name: "YourTarget",
  dependencies: [
    .product(name: "SupabaseLogger", package: "swift-log-supabase"),
  ]
)

Usage

Start by creating the logs table on Supabase dashboard by running the supabase-init.sql script on Supabase SQL Editor.

During app startup/initialization.

import Logging
import SupabaseLogging

LoggingSystem.bootstrap { label in 
  SupabaseLogHandler(
    label: label,
    config: SupabaseLogConfig(
      table: "logs", // optional table name to use, defaults to "logs".
      supabaseURL: "https://your-supabase-project-url.com/rest/v1",
      supabaseAnonKey: "your-supabase-anon-key",
      isDebug: true // optional flag to turn on/off internal logging, defaults to "false".
    )
  )
}

let logger = Logger(label: "co.binaryscraping.swift-log-supabase")
logger.info("Supabase is super cool")

For more details on all the features of the Swift Logging API, check out the swift-log repo.

Description

  • Swift Tools 5.6.0
View More Packages from this Author

Dependencies

Last updated: Thu Oct 17 2024 17:55:11 GMT-0900 (Hawaii-Aleutian Daylight Time)