All Projects → shial4 → LogSwift

shial4 / LogSwift

Licence: MIT license
Simple yet advanced swift logger

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to LogSwift

logback-access-spring-boot-starter
Spring Boot Starter for Logback-access.
Stars: ✭ 153 (+705.26%)
Mutual labels:  logger
ng2-logger
Isomorphic logger for Browser and NodeJS, ( typescript / javascript ) apps
Stars: ✭ 61 (+221.05%)
Mutual labels:  logger
EventLogger
Log event count and event time in iOS
Stars: ✭ 21 (+10.53%)
Mutual labels:  logger
JJSwiftLog
Swift log library for all platform
Stars: ✭ 51 (+168.42%)
Mutual labels:  logger
spdlog-python
python wrapper around C++ spdlog ([email protected]:gabime/spdlog.git)
Stars: ✭ 46 (+142.11%)
Mutual labels:  logger
QLogger
Multi-threading logger for Qt applications
Stars: ✭ 46 (+142.11%)
Mutual labels:  logger
LogDNA-Android-Client
Android client for LogDNA
Stars: ✭ 22 (+15.79%)
Mutual labels:  logger
hapi-good-winston
A good reporter to send and log events with winston
Stars: ✭ 21 (+10.53%)
Mutual labels:  logger
G-Earth
Cross-platform Habbo packet manipulator
Stars: ✭ 52 (+173.68%)
Mutual labels:  logger
base
OST Base provides advanced Promise Queue Manager and other utilities.
Stars: ✭ 19 (+0%)
Mutual labels:  logger
DRF-API-Logger
An API Logger for your Django Rest Framework project.
Stars: ✭ 184 (+868.42%)
Mutual labels:  logger
wlog
A simple logging interface that supports cross-platform color and concurrency.
Stars: ✭ 59 (+210.53%)
Mutual labels:  logger
RxLogs
An Android & Kotlin Reactive Advanced Logging Framework.
Stars: ✭ 12 (-36.84%)
Mutual labels:  logger
lines-logger
Browser logger that rests lines in peace
Stars: ✭ 26 (+36.84%)
Mutual labels:  logger
telegram-logger-errors
Telegram logger errors package laravel | Laravel пакет telegram логгер ошибок
Stars: ✭ 15 (-21.05%)
Mutual labels:  logger
perforce-commit-discord-bot
🗒️ ✏️Posts the most recent commit messages from a Perforce version control server to a Discord channel.
Stars: ✭ 22 (+15.79%)
Mutual labels:  logger
phoenix passwordless login
Phoenix Passwordless Login
Stars: ✭ 28 (+47.37%)
Mutual labels:  logger
babel-plugin-js-logger
Babel plugin to enable js-logger in your entire project efficiently.
Stars: ✭ 12 (-36.84%)
Mutual labels:  logger
winston-dev-console
Winston@3 console format aimed to improve development UX
Stars: ✭ 88 (+363.16%)
Mutual labels:  logger
Android-NativeLogger
Android Logger
Stars: ✭ 21 (+10.53%)
Mutual labels:  logger

SLLog

Swift 5.2 License Continuous Integration Codebeat

SLLog is a simple yet elegant swift logger. Allows you to log content to file, console or your custom target.

1990-02-19T22:45:36.250Z [VERBOSE] MyFile.swift:19 - 123
1991-03-20T20:33:44.777Z [INFO] MyFile.swift:20 - ABC
1992-04-21T09:53:51.021Z [DEBUG] MyFile.swift:21 - @$#!^%
1993-05-22T11:05:02.000Z [WARNING] MyFile.swift:22 - 2017-10-04 22:45:36 +0000
1994-06-23T15:13:00.146Z [ERROR] MyFile.swift:23 - [0.10000000000000001, 1, "A", 2017-10-04 09:55:36 +0000]

Terminal Console

🔧 Installation

Add the following dependency to your Package.swift file:

.package(url: "https://github.com/SLLog/SLLog", from: "1.1.0"),

💊 How To Start

1 Import

On top of your file import:

import SLLog

2 Usage

Log any information you need with Log class

Log.d("ABC")
Log.w("#%^$&@")
Log.e("1233")

Any object.

SLLog.addHandler(SLLogConsole())
Log.v(123)
Log.i("ABC")
Log.d("@$#!^%")
Log.w(Date())
Log.e([0.1,1,"A",Date()])

3 Initialize

Setup SLLoger

SLLog.addHandler(try! SLLogFile("path/to/directory"))

Or console handler

SLLog.addHandler(SLLogConsole())

or both

SLLog.addHandler(SLLogConsole(), try! SLLogFile(path))

You can create your custom log handler. Simply correspond to LogHandler protocol.

public class MyHandler: LogHandler {
    open func handle(message: Any, level: SLLog.LogType, file: String, line: UInt) {
        //Do your stuff with log.
    }
}

then add it to SLLog

SLLog.addHandler(MyHandler())

4 Providers

SLLog can have custom providers. To add your own provider

struct MySLLogProvider: LogProvider {}
SLLog.addProvider(MySLLogProvider())

can you can use LogProvider build in method send. To send your log via SLLog.

5 SLLogConsole

Default console log:

isDebug: Bool = true,
isTerminal: Bool = {
        #if Xcode
        return false
        #else
        return true
        #endif
    }(),
minProductionLogType: UInt = 3
logFormat: String = ":d :t :f::l :m",
dateFormat: String? = nil,
logColors: [SLLog.LogType:LogColor]? = nil

Override argument passing it in initializer to variate ConsoleLog SLLogConsole(isDebug: true, isTerminal: false) or SLLogConsole(isTerminal: false) and so on. Use isTerminal property to choose between terminal or console settings. SLLogConsole(isTerminal: false)

To fully configure SLLog pas Configuration object during initialisation. public init(_ config: Configuration = Configuration())

By default, logs are set for a terminal. log format ":d :t :f::l :m" where

`:d` is replaced in string to display date
`:t` is replaced by log type
`:f` is replaced by file name
`:l` is replaced by line number
`:m` is replaced by message object

Default date format used by logger is as follow "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"

To get rid of default log colors pass empty dictionary in logColors or dictionary with your own definitions. For more information about terminal color take a look: https://misc.flogisoft.com/bash/tip_colors_and_formatting

LogColor

LogColor is defined as follow init(_ terminal: String, _ console: String) For XCode console emoticons are used as collor.

SLLog.LogType.verbose:LogColor(TerminalColor.lightGray, "☑️"),
SLLog.LogType.info:LogColor(TerminalColor.lightCyan, "Ⓜ️"),
SLLog.LogType.debug:LogColor(TerminalColor.lightGreen, ""),
SLLog.LogType.warning:LogColor(TerminalColor.lightYellow, "⚠️"),
SLLog.LogType.error:LogColor(TerminalColor.lightRed, "⛔️"),

Use TerminalColor to fast access predefined colors values

5 SLLogFile

SLLogFile save logs to files which are created on daily basis. File names are as follows: "yyyy-MM-dd". Created under :yuorPath/sllogs with extension .log Default maxFilesCount is set to 3 wich means logger stores 3 files at a time. 1 file = 1 day logs

Contributing

Be welcome to contribute to this project! :)

Questions

You can create an issue on GitHub.

📝 License

This project was released under the MIT license.

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].