Skip to content

Pod that will help you associate logs with emojis

License

Notifications You must be signed in to change notification settings

adilanchian/LogMoji

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LogMoji

CI Status Version License Platform

LogMoji log statements being displayed

Introduction

LogMoji is here to help you parse through all your verbose log statements with meaningful, custom emojis that stand out! This simple logger has the ability to log to your console, a specified file path, or both! It also has the ability for you to set as many custom states as you would like. Make your log statements easier to read with LogMoji.

Getting Started

Installation

LogMoji is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'LogMoji'

Usage

LogMoji makes it easy for you to get up and running quickly and easily! For basic usage you follow these steps:

import LogMoji

enum LogStates: String, State {
    case success, critical, warning
    
    var emoji: String {
        switch self {
        case .critical: return "🚨"
        case .warning: return "⚠️"
         case .success: return ""
        }
    }
    
    var name: String { self.rawValue }
}

// Decide where to log & whether to show a timestamp
LogMoji.logger.logToConsole(true)
LogMoji.logger.setFilePath("Path/To/File.txt")
LogMoji.logger.showTimeStamp(false)

// Start Logging!
LogMoji.logger.logWith(state: Errors.success, message: "I am a successful LogMoji message!")
LogMoji.logger.logWith(state: Errors.warning, message: "I am a warning LogMoji message!")
LogMoji.logger.logWith(state: Errors.critical, message: "I am a CRITICAL LogMoji message!")

setStates(Dictionary<String, String>)

This method will take any number of states you would like to add to your app. Pass in an ID and associate it with the emoji of your choice!

logWith(state: String, message: String)

This is the main method to actually log anything with LogMoji. Make sure to set your states and settings before using this.

logToConsole(_ value: Bool)

Decide whether to log state to console.
Defaults to true

setFilePath(_ path: String?)

Set a file path of where you would like to output your logs! This has been tested with an absolute path only.
Defaults to nil

showTimeStamp(_ value: Bool)

Decide wether you would like a timestamp prepended to your log.
Defaults to true

defaultState

If a state cannot be found, the log statement will default to the defualtState emoji. This can be changed if desired.
Defaults to ❓

changeDefaultState(emoji: String)

Set the default state emoji in the chance a specified state could not be found.

Example Project

To run the example project, clone the repo, and run pod install from the Example directory first. This simple application shows you the very basics of LogMoji.

Author

Alec Dilanchian
Twitter
Twitch
Email

License

LogMoji is available under the MIT license. See the LICENSE file for more info.