swiftstack / log

General log system

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

About

General log system

License:The Unlicense


Languages

Language:Swift 98.2%Language:Shell 1.8%