Git Product home page Git Product logo

kylogger's Introduction

KYLogger

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.


macOS iOS watchOS
SPM CocoaPods Carthage

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:

class DemoAppFileLogger {
  public static var isDataSyncLoggingEnabled: Bool = false
}

public func DemoAppSyncFileLog(
  _ type: KYLogType,
  _ message: String,
  function: String = #function,
  file: String = #file,
  line: Int = #line
) {
#if DEBUG
  KYFileLogger.log(type, message, DemoAppFileLogger.isDataSyncLoggingEnabled, function: function, file: file, line: line)
#else
  if DemoAppFileLogger.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 project KYLoggerDemo for more details.

kylogger's People

Contributors

kjuly avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

yenomx aidemx

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.