All Projects → jezzmemo → JJSwiftLog

jezzmemo / JJSwiftLog

Licence: MIT license
Swift log library for all platform

Programming Languages

swift
15916 projects
shell
77523 projects
ruby
36898 projects - #4 most used programming language
objective c
16641 projects - #2 most used programming language

Projects that are alternatives of or similar to JJSwiftLog

l
Cross-platform html/io [L]ogger with simple API.
Stars: ✭ 26 (-49.02%)
Mutual labels:  log, logger, logging-library
clue
a extremely high performance log library for android. 高性能的Android日志库
Stars: ✭ 27 (-47.06%)
Mutual labels:  log, logger, logging-library
LogDNA-Android-Client
Android client for LogDNA
Stars: ✭ 22 (-56.86%)
Mutual labels:  log, logger, logging-library
Cocoadebug
iOS Debugging Tool 🚀
Stars: ✭ 3,769 (+7290.2%)
Mutual labels:  log, logger, logging-library
Quicklogger
Library for logging on files, console, memory, email, rest, eventlog, syslog, slack, telegram, redis, logstash, elasticsearch, influxdb, graylog, Sentry, Twilio, ide debug messages and throw events for Delphi/Firemonkey/freepascal/.NET (Windows/Linux/OSX/IOS/Android).
Stars: ✭ 137 (+168.63%)
Mutual labels:  log, logger
ng-logger
Angular logger service
Stars: ✭ 65 (+27.45%)
Mutual labels:  log, logger
Go Logger
一个简单而强大的 golang 日志工具包,支持同步和异步输出到 命令行,文件, api 接口,文件支持按文件大小,文件行数,日期切分;A simple and powerful golang logging toolkit that supports synchronous and asynchronous output to the console, file, API interfaces, file support by file size, file line number, date sharding.
Stars: ✭ 152 (+198.04%)
Mutual labels:  log, logger
log
Aplus Framework Log Library
Stars: ✭ 14 (-72.55%)
Mutual labels:  log, logger
Rain
Visualize vertical data inside your terminal 💦
Stars: ✭ 84 (+64.71%)
Mutual labels:  log, logger
Heliumlogger
A lightweight logging framework for Swift
Stars: ✭ 169 (+231.37%)
Mutual labels:  log, logger
Lajax
🚀 lajax - 前端日志解决方案。
Stars: ✭ 181 (+254.9%)
Mutual labels:  log, logger
Easylogger
An ultra-lightweight(ROM<1.6K, RAM<0.3k), high-performance C/C++ log library. | 一款超轻量级(ROM<1.6K, RAM<0.3k)、高性能的 C/C++ 日志库
Stars: ✭ 1,968 (+3758.82%)
Mutual labels:  log, logger
Serverlog
A simple, practical and innovative Node.js log library that enables you to view logs in Chrome dev tools and browser Console.
Stars: ✭ 117 (+129.41%)
Mutual labels:  log, logger
Node Lambda Log
Basic logging mechanism for Node 6.10+ Lambda Functions
Stars: ✭ 115 (+125.49%)
Mutual labels:  log, logger
Logcat
Android 日志打印框架,在手机上可以直接看到 Logcat 日志啦
Stars: ✭ 189 (+270.59%)
Mutual labels:  log, logger
Easy Log Handler
Human-friendly log files that make you more productive
Stars: ✭ 2,070 (+3958.82%)
Mutual labels:  log, logger
Acho
The Hackable Log
Stars: ✭ 189 (+270.59%)
Mutual labels:  log, logger
Xlog
Android logger, pretty, powerful and flexible, log to everywhere, save to file, all you want is here.
Stars: ✭ 2,468 (+4739.22%)
Mutual labels:  log, logger
Golog
A high-performant Logging Foundation for Go Applications. X3 faster than the rest leveled loggers.
Stars: ✭ 208 (+307.84%)
Mutual labels:  log, logger
Loguru
Python logging made (stupidly) simple
Stars: ✭ 10,510 (+20507.84%)
Mutual labels:  log, logger

Swift4.0+ CocoaPods Compatible Carthage Compatible Platform License MIT

JJSwiftLog

JJSwiftLog screenshot

Keep the Swift log concise, and also take into account the basic functions of the log, file name, function name, number of lines and other information, built-in console and file log functions, to meet the basic needs of developers, custom logs for developers to be highly flexible.

Feature

  • Console display (Console Log), taking into account the features of NSLog

  • Log file storage (File Log), advanced properties of configuration file log

  • User-defined log, inherits JJLogObject

  • Global switch log

  • Show only the specified file log

  • Custom log filter

  • Custom log format, any combination, built-in styles for developers to choose, built-in ANSIColor format

  • Supports multi-platform iOS, MacOS, Windows and Linux

Install

  • Swift 4.0+

Podfile

pod 'JJSwiftLog'

Carthage

github "jezzmemo/JJSwiftLog"

Swift Package Manager

.package(url: "https://github.com/jezzmemo/JJSwiftLog.git"),

How to use

Quick to use

  • Import module
import JJSwiftLog
  • Quick start

It is generally recommended to initialize at the entry of the program. The console and file log are configured by default. You only need to configure the log level. example:

override func viewDidLoad() {
    super.viewDidLoad()
    JJLogger.setup(level: .verbose)

    JJLogger.verbose("verbose")
    JJLogger.debug("debug")
    JJLogger.info("info")
    JJLogger.warning("warn")
    JJLogger.error("error")
}

Advanced

  • The developer configures the log
override func viewDidLoad() {
     super.viewDidLoad()
     // filePath needs to store the path
     var file = JJFileOutput(filePath: "filePath", delegate: JJLogger, identifier: "file")
     file?.targetMaxFileSize = 1000 * 1024
     file?.targetMaxTimeInterval = 600
     file?.targetMaxLogFiles = 20
     JJLogger.addLogOutput(file)
     #if DEBUG
     JJLogger.addLogOutput(JJConsoleOutput(identifier: "console"))
     #endif
     // Note the timing of the startLogInfo call
     JJLogger.startLogInfo()
     JJLogger.verbose("verbose")
     JJLogger.debug("debug")   
     JJLogger.info("info")
     JJLogger.warning("warn")
     JJLogger.error("error")
     // Any type
     JJLogger.verbose(123)
     JJLogger.debug(1.2)
     JJLogger.info(Date())
     JJLogger.warning(["1", "2"])
}
  • JJConsoleOutput use the NSLog style, use the isUseNSLog property
let console = JJConsoleOutput()
console.isUseNSLog = false
  • JJFileOutputThere are several properties to adjust the storage file strategy

    • targetMaxFileSizeMaximum file size

    • targetMaxTimeIntervalGenerate new file interval

    • targetMaxFileSizeThe maximum number of files, if this number is exceeded, the previous files will be deleted

let file = JJFileOutput()
file?.targetMaxFileSize = 1000 * 1024
file?.targetMaxTimeInterval = 600
file?.targetMaxLogFiles = 20
  • Set enable to switch logging in real time, which is enabled by default
JJLogger.enable = true
  • Set the onlyLogFile method to make the specified file display logs
JJLogger.onlyLogFile("ViewController")
  • JJSwiftLog supports custom format logs. The following table is the correspondence between abbreviated letters:
Shorthand Describtion
%M log text
%L log level
%l log line
%F filename, without suffix
%f Function name
%D Date (currently only yyyy-MM-dd HH:mm:ss.SSSZ is supported)
%T Thread, if the main thread displays main, the child thread displays the address or QueueLabel
%t Display HH:mm:ss format
%d Display yyyy-MM-dd format
%N filename, with suffix

Example:

JJLogger.format = "%M %F %L%l %f %D"

There are also built-in styles, such as: JJLogger.format = JJSwiftLog.simpleFormat, example:

2020-04-08 22:56:54.888+0800 -> ViewController:18 - setupVendor(parameter:) method set the parameter
2020-04-08 22:56:54.889+0800 -> ViewController:28 - viewDidLoad() Start the record
2020-04-08 22:56:54.889+0800 -> ViewController:29 - viewDidLoad() Debug the world
2020-04-08 22:56:54.890+0800 -> ViewController:30 - viewDidLoad() Show log info
2020-04-08 22:56:54.890+0800 -> ViewController:31 - viewDidLoad() Build warning
2020-04-08 22:56:54.890+0800 -> ViewController:32 - viewDidLoad() can’t fetch user info without user id
  • Implement the custom interface JJLogObject as needed, the example:
public class CustomerOutput: JJLogObject {
    ///重写output即可
    open override func output(log: JJLogEntity, message: String) {

    }
    
}
  • Each JJLogObject corresponds to a formatters (formatting) and filters (filtering) attributes. You can customize the formatting and filters according to your own needs. Example:
open class CustomerFormatter: JJLogFormatterProtocol {
    public func format(log: JJLogEntity, message: String) -> String {
        return ""
    }
}
open class CustomerFilter: JJLogFilter {
    func ignore(log: JJLogEntity, message: String) -> Bool {
        return false
    }
}
  • Built-in JJFormatterLogANSIColor, you can use the terminal to view the log with color, just add the following in formatters:

The xcode console does not support ANSIColor mode, currently only tested on the terminal

let file = JJFileOutput(delegate: JJLogger, identifier: "file")
file?.targetMaxFileSize = 1000 * 1024
file?.targetMaxTimeInterval = 600
file?.targetMaxLogFiles = 20
file?.formatters = [JJFormatterLogANSIColor()]
JJLogger.addLogOutput(file!)

Example:

JJSwiftLog ANSIColor

  • Support Sentry, example:
let sentry = JJSentryOutput(sentryKey: "key", 
sentryURL: URL(string: "http://www.exmaple.com/api/5/store/")!, delegate: JJLogger)
sentry.completion = { result in
}
sentry.failure = { error in
}
JJLogger.addLogOutput(sentry)

Linker

License

JJSwiftLog is released under the MIT license. See LICENSE for details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].