Skip to content

swiftstack/log

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Log

Simple log module.

Package.swift

.package(url: "https://github.com/swiftstack/log.git", .branch("dev"))

Memo

public enum Level: String {
    case debug, info, warning, error, critical
}

func log(event: Level, message: String)

struct Log {
    static var disabled: Bool = false
    static var delegate: ((Level, String) -> Void)

    static func debug(_ message: String)
    static func info(_ message: String)
    static func warning(_ message: String)
    static func error(_ message: String)
    static func critical(_ message: String)
}

Usage

Log.info("message")

// Overwrite delegate
Log.delegate = { level, message in
    if level != .debug {
        print("[\(level)] \(message)")
    }
}

// Disable logging
Log.disabled = true

Releases

No releases published

Packages

No packages published