8000 GitHub - dalu93/Log: Lightweight, pluggable, pure Swift logging library ๐Ÿ“
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

dalu93/Log

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

10 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Log ๐Ÿ“

Lightweight, pluggable, pure Swift logging library

Installation

705D

You can install Log ๐Ÿ“ with SPM

  1. Add or amend a Package.swift
  2. Add this dependency .package(url: "https://github.com/dalu93/Log.git", from: "1.0.0")
  3. Then import Log in your code and start using it ๐ŸŽ‰

Usage

log.error("something wrong happened")

Easy right? By default, Log comes with a set of LogLevels which should cover, more or less, all the use cases: debug, info, notice, warning and error. It also provides few utility methods that you can access as below:

log.debug("message", isVerbose: true)
log.info("message")
log.notice("message")
log.warning("message")
log.error("message")

Destinations

By using the default log instance, your logs are going to be sent to terminal output. If you want to change this behavior, define your own Destination by confirming to LogDestination protocol

struct LocalFileDestination: LogDestination {
    func log(_ message: @autoclosure () -> String) {
        // log to file here...
    }
}

And then, initialize your own Logger instance

let logger = Logger(
    destinations: [
        LocalFileDestination(),
        TerminalDestination()
    ],
    isVerbose: false
)

This code will send the logs to each LogDestination which is passed to the Logger instance.

About

Lightweight, pluggable, pure Swift logging library ๐Ÿ“

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

0