Swiftpack.co - CodeNationDev/SimplyLogger as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by CodeNationDev.
CodeNationDev/SimplyLogger 0.0.8
Simply Swift logging
⭐️ 1
πŸ•“ 2 years ago
iOS macOS watchOS tvOS
.package(url: "https://github.com/CodeNationDev/SimplyLogger.git", from: "0.0.8")

╔═══╗──────╔╗────╔╗ ║╔═╗║──────║║────║║ β•‘β•šβ•β•β•¦β•¦β•—β•”β•¦β•β•β•£β•‘β•”β•—β”€β•”β•£β•‘β”€β”€β•”β•β•β•¦β•β•β•¦β•β•β•¦β•β•β•¦β•β•— β•šβ•β•β•—β• β•£β•šβ•β•‘β•”β•—β•‘β•‘β•‘β•‘β”€β•‘β•‘β•‘β”€β•”β•£β•”β•—β•‘β•”β•—β•‘β•”β•—β•‘β•‘β•β•£β•”β• β•‘β•šβ•β•β•‘β•‘β•‘β•‘β•‘β•šβ•β•‘β•šβ•£β•šβ•β•β•‘β•šβ•β•β•‘β•šβ•β•‘β•šβ•β•‘β•šβ•β•‘β•‘β•β•£β•‘ β•šβ•β•β•β•©β•©β•©β•©β•£β•”β•β•©β•β•©β•β•—β•”β•©β•β•β•β•©β•β•β•©β•β•—β• β•β•—β• β•β•β•©β• ────────║║───╔═╝║───────╔═╝╠═╝║ β”€β”€β”€β”€β”€β”€β”€β”€β•šβ•β”€β”€β”€β•šβ•β•β•β”€β”€β”€β”€β”€β”€β”€β•šβ•β•β•©β•β•β•

A simple logger for Swift.

Installation

Use Swift Package Manager to add this package to your project.

Definition & Interface

public static func log(str: String, 
                   appName: String? = nil, 
                   identity: String? = nil, 
                   logToSystem: Bool? = false, 
                   category: LogCategory, 
                   type: OSLogType? = .debug, 
                   log: OSLog? = .default)
  • str (String): logging message

  • appName (String): app name to show at log header.

  • identity (String): name of log.

  • logToSystem (Bool): parameter for write log in system log console or not. Default is FALSE.

  • category (enum): the log category options:

    public enum LogCategory: String {
        case success = "βœ…βœ…"
        case info = "ℹ️ℹ️"
        case warning = "⚠️⚠️"
        case error = "🧨🧨"
        case viewcycle = "πŸ“±πŸ“±"
        case data = "πŸ—„πŸ—„"
        case service = "πŸ“¬πŸ“¬"
        case trace = "πŸ”ΈπŸ”Έ"
    }
    
  • type (OSLogType): type of OSLog for system console.

  • log (OSLog): the log write.

Usage example

Custom Log

//
import UIKit
import os.log

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        SimplyLogger.log(str: "Testing logging", logToSystem: true, category: .error, type: .error)
    }
}

Logging traces

//
import UIKit
import os.log

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        SimplyLogger.trace(str: "view did loaded")
    }
}

Also, you can do a complex trace using custom log with "trace" category.

 SimplyLogger.log(str: "Testing logging", logToSystem: true, category: .trace, type: .debug)

ROADMAP

  • Store logs in BBDD for check and analyze behaviors (CoreData, Realm, SQLite...)
  • Retrieve logs sliced in blocks.
  • Set limits of number of logs stored.

Meta

David Martin Saiz – @deividmarshall – [email protected]

Distributed under the MIT license. See LICENSE for more information.

https://github.com/CodeNationDev/

Version History

  • 0.0.8
    • Fixed
      • log type
    • Updated
      • Info icon
    • Added
      • Success category
  • 0.0.7
    • Update log function and prints.
    • Deprecate trace function.
  • 0.0.6
    • Add compatibility with watchOS, macOS and tvOS.
  • 0.0.5
    • Set Swift minumim version to 5.0.
  • 0.0.4
    • Add date time to log trace.
  • 0.0.3
    • Adjust iOS version to 11.
  • 0.0.2
    • Add Swift Package Manager Support.
  • 0.0.1
    • First implementation with main features.

GitHub

link
Stars: 1
Last commit: 2 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics