Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

A local system logger for Apple platforms.

License

NotificationsYou must be signed in to change notification settings

Kjuly/KYLogger

Repository files navigation

A local system logger for Apple platforms.

This lightweight logging lib is serverless. It includes a debug logger and a file logger which will save logs locally on the device. Users can choose to send a log file when a bug is reported.


macOSiOSwatchOS
SPMCocoaPodsCarthage

Installation

See the following subsections for details on the different installation methods.

KYLog Usage

KYLog(.debug,"A debug message")KYLog(.notice,"A notice message")KYLog(.success,"A success message")KYLog(.warn,"A warn message")KYLog(.error,"A error message")KYLog(.critical,"A critical message")

Outputs:

🟣 DEBUG -[KYLoggerDemoApp.swift init()] L18: A debug message🔵 NOTICE -[KYLoggerDemoApp.swift init()] L19: A notice message🟢 SUCCESS -[KYLoggerDemoApp.swift init()] L20: A success message🟡 WARN -[KYLoggerDemoApp.swift init()] L21: A warn message🔴 ERROR -[KYLoggerDemoApp.swift init()] L22: A error message❌ CRITICAL -[KYLoggerDemoApp.swift init()] L23: A critical message

KYFileLogger Usage

You can define a global variable to toggle file logging and wrap the logger with a convenience function. Just like the demo project:

classDemoAppFileLogger{publicstaticvarisDataSyncLoggingEnabled:Bool=false}publicfunc DemoAppSyncFileLog(  _ type:KYLogType,  _ message:String,  function:String= #function,  file:String= #file,  line:Int= #line){#if DEBUGKYFileLogger.log(type, message,DemoAppFileLogger.isDataSyncLoggingEnabled, function: function, file: file, line: line)#elseifDemoAppFileLogger.isDataSyncLoggingEnabled{KYFileLogger.log(type, message, function: function, file: file, line: line)}#endif}// This message will be saved to disk only if `DemoAppFileLogger.isDataSyncLoggingEnabled = true`.DemoAppSyncFileLog(.notice,"Some sync messages.")

Note

You can check out the demo projectKYLoggerDemo for more details.


[8]ページ先頭

©2009-2025 Movatter.jp