Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Shial committed Oct 13, 2017
1 parent a322ed7 commit 3585f6b
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 10 deletions.
Binary file added Images/console.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/terminal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 12 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ SLLog is a simple yet elegant swift logger. Allows you to log content to file, c
1994-06-23T15:13:00.146Z [ERROR] MyFile.swift:23 - [0.10000000000000001, 1, "A", 2017-10-04 09:55:36 +0000]
```

<p align="center">
<img src="Images/terminal.png" alt="Terminal" />
<img src="Images/console.png" alt="Console" />
</p>

## 🔧 Installation

Add the following dependency to your `Package.swift` file:
Expand Down Expand Up @@ -129,12 +134,14 @@ For more information about terminal color take a look: `https://misc.flogisoft.c
LogColor is defined as follow `init(_ terminal: String, _ console: String)`
For XCode console emoticons are used as collor.
```swift
SLLog.LogType.verbose:LogColor("37m", "☑️"),
SLLog.LogType.info:LogColor("34m", "Ⓜ️"),
SLLog.LogType.debug:LogColor("92m", ""),
SLLog.LogType.warning:LogColor("93mm", "⚠️"),
SLLog.LogType.error:LogColor("91m", "⛔️"),
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 create on daily basis.
File names are as follows: `"yyyy-MM-dd"`. Created under `:yuorPath/sllogs` with extension `.log`
Expand Down
30 changes: 25 additions & 5 deletions Sources/SLLog/SLLogConsole.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,26 @@

import Foundation

public class TerminalColor {
class var `default`: String { return "39m" }
class var black: String { return "30m" }
class var red: String { return "31m" }
class var green: String { return "32m" }
class var yellow: String { return "33m" }
class var blue: String { return "34m" }
class var magenta: String { return "35m" }
class var cyan: String { return "36m" }
class var lightGray: String { return "37m" }
class var darkGray: String { return "90m" }
class var lightRed: String { return "91m" }
class var lightGreen: String { return "92m" }
class var lightYellow: String { return "93m" }
class var lightBlue: String { return "94m" }
class var lightMagenta: String { return "95m" }
class var lightCyan: String { return "96m" }
class var white: String { return "97m" }
}

public struct LogColor {
public init(_ terminal: String, _ console: String) {
self.terminalColor = terminal
Expand Down Expand Up @@ -40,11 +60,11 @@ public class SLLogConsole: LogHandler {
public var isTerminal: Bool
public var logFormat: String
public var logColors: [SLLog.LogType:LogColor] = [
SLLog.LogType.verbose:LogColor("37m", "☑️"),
SLLog.LogType.info:LogColor("34m", "Ⓜ️"),
SLLog.LogType.debug:LogColor("92m", ""),
SLLog.LogType.warning:LogColor("93mm", "⚠️"),
SLLog.LogType.error:LogColor("91m", "⛔️"),
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, "⛔️"),
]

private var formattert: DateFormatter = DateFormatter(dateFormat: "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'",
Expand Down
13 changes: 13 additions & 0 deletions Tests/SLLogTests/SLLogConsoleTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ import Foundation
class SLLogConsoleTests: XCTestCase {
static var allTests = [
("testLogs", testLogs),
("testTerminal", testTerminal),
]

func testLogs() {
SLLog.clearHandlers()
SLLog.addHandler(SLLogConsole(isTerminal: false))
SLLog.v(123)
SLLog.i("ABC")
Expand All @@ -23,4 +25,15 @@ class SLLogConsoleTests: XCTestCase {
SLLog.e([0.1,1,"A",Date()])
XCTAssert(true)
}

func testTerminal() {
SLLog.clearHandlers()
SLLog.addHandler(SLLogConsole(isTerminal: true))
SLLog.v(123)
SLLog.i("ABC")
SLLog.d("@$#!^%")
SLLog.w(Date())
SLLog.e([0.1,1,"A",Date()])
XCTAssert(true)
}
}

0 comments on commit 3585f6b

Please sign in to comment.