Swiftpack.co - Schlaubischlump/CLogger as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by Schlaubischlump.
Schlaubischlump/CLogger v0.0.1
A simple swift wrapper for c-logger
⭐️ 1
🕓 2 years ago
.package(url: "https://github.com/Schlaubischlump/CLogger.git", from: "v0.0.1")

CLogger

A simple swift-wrapper around c-logger. This is useful if you need a logging library, that works across C, Objectice-C and Swift. C-logger does implement the logging with macros, which is not supported in Swift. Therefore helper functions around these macros are provided for Swift, such as logInfo or logError.

Step 1: Initialize the logger in Swift:

// Flush every 5 seconds
logger_autoFlush(5000) 
// Init the console logger
logger_initConsoleLogger(nil)
// Init the file logger with a 5MB limit per file
logger_initFileLogger("Some/Path/To/A/LogFile, 1024*1024*5, 5)
// You can use the rest of the C-API as well

Step 2: Usage in Swift:

// Since swift does not support C Macros, use the helper functions
let myValue = 3
logInfo("Some string with value: \(myValue)")

Step 3: Usage in C or Objective-C

int myValue = 3; 
LOG_INFO("Some string with value: %d", myValue);

GitHub

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

Related Packages

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