A simple logging package for Swift

Overview

OhMyLog

OhMyLog is a simple logging package for Swift. It supports the following features:

  • Six logging levels ( 👣 , 🔍 , 💡 , ⚠️ , 🚨 , 💊 )
  • Display log context including filename and line number

Install 🔧

You package file would be like:

let package = Package(
    name: "YourPackageName",
    
    dependencies: [
        .package(url: "https://github.com/forkercat/OhMyLog.git", .branch("main")),
    ],
    
    targets: [
        .executableTarget(
            name: "YourPackageName",
            dependencies: [
                .product(name: "OhMyLog", package: "OhMyLog")
            ]),
    ]
)

Usage 😆

Option 1: Use Logger object

import OhMyLog

let list = ["Oh", "My", "Log"]

var logger = Logger(name: "MyProject", level: .info)
logger.logLevel = .trace
logger.trace("Hello, World! \(list)")
logger.debug("Hello, World! \(list)")
logger.info("Hello, World! \(list)")
logger.warn("Hello, World! \(list)")
logger.error("Hello, World! \(list)")
logger.fatal("Hello, World! \(list)")

// Output
[👣TRACE] MyProject main.swift:24 - Hello, World! ["Oh", "My", "Log"]
[🔍DEBUG] MyProject main.swift:25 - Hello, World! ["Oh", "My", "Log"]
[💡INFO ] MyProject main.swift:26 - Hello, World! ["Oh", "My", "Log"]
[⚠️WARN ] MyProject main.swift:27 - Hello, World! ["Oh", "My", "Log"]
[🚨ERROR] MyProject main.swift:28 - Hello, World! ["Oh", "My", "Log"]
[💊FATAL] MyProject main.swift:29 - Hello, World! ["Oh", "My", "Log"]

Option 2: Use Log namespace

import OhMyLog

let list = ["Oh", "My", "Log"]

Log.registerLogger(name: "MyProject", level: .info)
Log.setLevel(level: .info)
Log.info("Hello, World! \(list)")

// Output
[💡INFO ] MyProject main.swift:26 - Hello, World! ["Oh", "My", "Log"]

Option 3: Without import (recommended)

Create a swift source file in your project with two lines.

import OhMyLog

typealias Log = OhMyLog.Log

Now you are able to log without import OhMyLog.

let list = ["Oh", "My", "Log"]

Log.registerLogger(name: "MyProject", level: .info)
Log.setLevel(level: .info)
Log.info("Hello, World! \(list)")

// Output
[💡INFO ] MyProject main.swift:26 - Hello, World! ["Oh", "My", "Log"]

Reference

You might also like...
Swift Logging Utility for Xcode & Google Docs
Swift Logging Utility for Xcode & Google Docs

QorumLogs Swift Logging Utility in Xcode & Google Docs

A lightweight logging framework for Swift

HeliumLogger Provides a lightweight logging implementation for Swift which logs to standard output. Features Logs output to stdout by default. You can

A lightweight logging framework for Swift

HeliumLogger Provides a lightweight logging implementation for Swift which logs to standard output. Features Logs output to stdout by default. You can

A flexible logging library written in Swift

Puppy Puppy is a flexible logging library written in Swift 🐶 It supports multiple transports(console, file, syslog, and oslog) as loggers. It not onl

An extensible logging framework for Swift
An extensible logging framework for Swift

Log is a powerful logging framework that provides built-in themes and formatters, and a nice API to define your owns. Get the most out of Log by insta

Logging utility for Swift and Objective C
Logging utility for Swift and Objective C

Swell - Swift Logging A logging utility for Swift and Objective C. ##Features Turn on logging during development, turn them off when building for the

A powerful input-agnostic swift logging framework made to speed up development with maximum readability.
A powerful input-agnostic swift logging framework made to speed up development with maximum readability.

The Swift logging framework. Atlantis is an extremely powerful logging framework that I've created for everyday use, including enterprise development

Most natural Swift logging

Evergreen Most natural Swift logging Evergreen is a logging framework written in Swift. It is designed to work just as you would expect, yet so versat

Spy is a flexible, lightweight, multiplatform logging utility written in pure Swift.
Spy is a flexible, lightweight, multiplatform logging utility written in pure Swift.

Spy is a flexible, lightweight, multiplatform logging utility written in pure Swift. It allows to log with different levels and on different channels. You can define what levels and channels actually are.

Releases(v1.1.0)
Owner
Junhao Wang
Protect the light in heart.
Junhao Wang
Twitter Logging Service is a robust and performant logging framework for iOS clients

Twitter Logging Service Background Twitter created a framework for logging in order to fulfill the following requirements: fast (no blocking the main

Twitter 290 Nov 15, 2022
A simple logging package for Swift

OhMyLog OhMyLog is a simple logging package for Swift. It supports the following features: Six logging levels ( ?? , ?? , ?? , ⚠️ , ?? , ?? ) Display

Junhao Wang 1 Jan 10, 2022
CleanroomLogger provides an extensible Swift-based logging API that is simple, lightweight and performant

CleanroomLogger CleanroomLogger provides an extensible Swift-based logging API that is simple, lightweight and performant. The API provided by Cleanro

null 1.3k Dec 8, 2022
TraceLog is a highly configurable, flexible, portable, and simple to use debug logging system for Swift and Objective-C applications running on Linux, macOS, iOS, watchOS, and tvOS.

Please star this github repository to stay up to date. TraceLog Introduction TraceLog is a highly configurable, flexible, portable, and simple to use

Tony Stone 52 Oct 28, 2022
Simple, lightweight and flexible debug logging framework written in Swift

AELog Simple, lightweight and flexible debug logging minion written in Swift If you find yourself in upcoming statements, then you probably want to us

Marko Tadić 28 Jul 6, 2022
Simple logging for simples needs.

Simple logging for simples needs.

native.dev.br 0 May 30, 2022
A fast & simple, yet powerful & flexible logging framework for Mac and iOS

CocoaLumberjack CocoaLumberjack is a fast & simple, yet powerful & flexible logging framework for macOS, iOS, tvOS and watchOS. How to get started Fir

null 12.9k Jan 9, 2023
A simple, straightforward logging API.

Sequoia A simple, straightforward logging API. Install Add the following to your Package.swift file: import PackageDescription let package = Package(

Jordan Baird 0 Dec 18, 2022
Convenient & secure logging during development & release in Swift 3, 4 & 5

Colorful, flexible, lightweight logging for Swift 3, Swift 4 & Swift 5. Great for development & release with support for Console, File & cloud platfor

SwiftyBeaver 5.6k Jan 4, 2023
Willow is a powerful, yet lightweight logging library written in Swift.

Willow Willow is a powerful, yet lightweight logging library written in Swift. Features Requirements Migration Guides Communication Installation Cocoa

Nike Inc. 1.3k Nov 16, 2022