Skip to content

Commit aacb930

Browse files
authored
Merge pull request #6 from VishwaiOSDev/fix/vishwa/renamed-log-to-logger
2 parents 9b0cd08 + 58548bd commit aacb930

File tree

6 files changed

+117
-115
lines changed

6 files changed

+117
-115
lines changed

Package.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
import PackageDescription
55

66
let package = Package(
7-
name: "LogKit",
7+
name: "LoggerKit",
88
platforms: [.iOS(.v13), .watchOS(.v6), .macOS(.v10_15), .tvOS(.v13)],
99
products: [
1010
// Products define the executables and libraries a package produces, and make them visible to other packages.
11-
.library(name: "LogKit", targets: ["LogKit"]),
11+
.library(name: "LoggerKit", targets: ["LoggerKit"]),
1212
],
1313
dependencies: [
1414
// Dependencies declare other packages that this package depends on.
@@ -17,7 +17,7 @@ let package = Package(
1717
targets: [
1818
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
1919
// Targets can depend on other targets in this package, and on products in packages this package depends on.
20-
.target(name: "LogKit", dependencies: []),
21-
.testTarget(name: "LogKitTests", dependencies: ["LogKit"]),
20+
.target(name: "LoggerKit", dependencies: []),
21+
.testTarget(name: "LoggerKitTests", dependencies: ["LoggerKit"]),
2222
]
2323
)

README.md

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
![LogKit](https://user-images.githubusercontent.com/71421776/182191029-877eeb22-282c-482a-8d89-6118dd150dbb.jpg)
1+
![LoggerKit](https://user-images.githubusercontent.com/71421776/182191029-877eeb22-282c-482a-8d89-6118dd150dbb.jpg)
22

3-
# LogKit
3+
# LoggerKit
44
A logger for Xcode
55

66
## Motivation
7-
LogKit is designed to be a simple and universal logging library with support for multiple Xcode projects. LogKit will have different types of log level.
7+
LoggerKit is designed to be a simple and universal logging library with support for multiple Xcode projects. LogKit will have different types of log level.
88

99
## Features
1010

@@ -19,6 +19,8 @@ LogKit is designed to be a simple and universal logging library with support for
1919
- Debug
2020
- Warning
2121
- Error
22+
- Initialize (init)
23+
- Teardown (deinit)
2224

2325
## 📦 Installation
2426

@@ -27,40 +29,40 @@ The [Swift Package Manager](https://swift.org/package-manager/) is a tool for au
2729

2830
Add this Swift package in Xcode using its Github repository url. (File > Swift Packages > Add Package Dependency...)
2931

30-
Add this URL https://github.com/VishwaiOSDev/LogKit.git and select **Add Package**.
32+
Add this URL https://github.com/VishwaiOSDev/LoggerKit.git and select **Add Package**.
3133

3234
After adding it select LogKit.
3335

3436
<img width="648" alt="Screenshot 2022-08-01 at 9 14 56 PM" src="https://user-images.githubusercontent.com/71421776/182190544-0dbdd51a-df00-44f2-9064-cd33e44d192b.png">
3537

3638
### 🚀 How to use
3739

38-
LogKit makes your life easier
40+
LoggerKit makes your life easier
3941

40-
Firstly, import the LogKit
42+
Firstly, import the LoggerKit
4143

4244
```swift
43-
import LogKit
45+
import LoggerKit
4446
```
4547

4648
For logging,
4749

4850
```swift
49-
Log.verbose("Example of verbose log.")
50-
Log.info("Something went wrong")
51-
Log.debug("Debug mode enabled")
52-
Log.warning("Warning, duplication warning.")
53-
Log.error("Error, data didn't fetch properly.")
51+
LoggerKit.verbose("Example of verbose log.")
52+
LoggerKit.info("Something went wrong")
53+
LoggerKit.debug("Debug mode enabled")
54+
LoggerKit.warning("Warning, duplication warning.")
55+
LoggerKit.error("Error, data didn't fetch properly.")
5456
```
5557

56-
LogKit will provide clean information for you. Output for above code as follows:
58+
LoggerKit will provide clean information for you. Output for above code as follows:
5759

5860
```
59-
[VERBOSE ✏️✏️] Example of verbose log. → LogKitTests.swift:7 testVerboseLog()
60-
[INFO ℹ️ℹ️] Something went wrong. → LogKitTests.swift:12 testInfoLog()
61-
[DEBUG 🚀🚀] Debug mode enabled → LogKitTests.swift:17 testDebugLog()
62-
[WARN ⚠️⚠️] Warning, duplication warning. → LogKitTests.swift:22 testWarningLog()
63-
[ERROR ❌❌] Error, data didn't fetch properly. → LogKitTests.swift:27 testErrorLog()
61+
💜💜 LoggerKitTests.swift: 49 - Something went wrong! Dependency Error.
62+
💚💚 LoggerKitTests.swift: 46 - Something went wrong! Dependency Error.
63+
💛💛 LoggerKitTests.swift: 19 - Debug mode enabled
64+
🧡🧡 LoggerKitTests.swift: 23 - Warning, duplication warning.
65+
❤️❤️ LoggerKitTests.swift: 45 - Something went wrong! Dependency Error.
6466
```
6567
# License
66-
LogKit is released under the MIT license.
68+
LoggerKit is released under the MIT license.

Sources/LogKit/LogKit+Extension.swift renamed to Sources/LoggerKit/LoggerKit+Extension.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,40 +17,40 @@ protocol Loggable {
1717
static func teardown(_ message: Any?..., shouldLogContext: Bool, file: String, line: Int)
1818
}
1919

20-
public extension Log {
20+
public extension Logger {
2121

2222
static func info(_ message: Any?..., shouldLogContext: Bool = true, file: String = #file, line: Int = #line) {
2323
let context = Context(file: file, line: line)
24-
Log.handleLog(level: .info, message: message, shouldLogContext: shouldLogContext, context: context)
24+
Logger.handleLog(level: .info, message: message, shouldLogContext: shouldLogContext, context: context)
2525
}
2626

2727
static func verbose(_ message: Any?..., shouldLogContext: Bool = true, file: String = #file, line: Int = #line) {
2828
let context = Context(file: file, line: line)
29-
Log.handleLog(level: .verbose, message: message, shouldLogContext: shouldLogContext, context: context)
29+
Logger.handleLog(level: .verbose, message: message, shouldLogContext: shouldLogContext, context: context)
3030
}
3131

32-
static func debug(_ message: Any?..., shouldLogContext: Bool = false, file: String = #file, line: Int = #line) {
32+
static func debug(_ message: Any?..., shouldLogContext: Bool = true, file: String = #file, line: Int = #line) {
3333
let context = Context(file: file, line: line)
34-
Log.handleLog(level: .debug, message: message, shouldLogContext: shouldLogContext, context: context)
34+
Logger.handleLog(level: .debug, message: message, shouldLogContext: shouldLogContext, context: context)
3535
}
3636

3737
static func warning(_ message: Any?..., shouldLogContext: Bool = true, file: String = #file, line: Int = #line) {
3838
let context = Context(file: file, line: line)
39-
Log.handleLog(level: .warning, message: message, shouldLogContext: shouldLogContext, context: context)
39+
Logger.handleLog(level: .warning, message: message, shouldLogContext: shouldLogContext, context: context)
4040
}
4141

4242
static func error(_ message: Any?..., shouldLogContext: Bool = true, file: String = #file, line: Int = #line) {
4343
let context = Context(file: file, line: line)
44-
Log.handleLog(level: .error, message: message, shouldLogContext: shouldLogContext, context: context)
44+
Logger.handleLog(level: .error, message: message, shouldLogContext: shouldLogContext, context: context)
4545
}
4646

4747
static func initialize(_ message: Any?..., shouldLogContext: Bool = true, file: String = #file, line: Int = #line) {
4848
let context = Context(file: file, line: line)
49-
Log.handleLog(level: .`init`, message: message, shouldLogContext: shouldLogContext, context: context)
49+
Logger.handleLog(level: .`init`, message: message, shouldLogContext: shouldLogContext, context: context)
5050
}
5151

5252
static func teardown(_ message: Any?..., shouldLogContext: Bool = true, file: String = #file, line: Int = #line) {
5353
let context = Context(file: file, line: line)
54-
Log.handleLog(level: .deinit, message: message, shouldLogContext: shouldLogContext, context: context)
54+
Logger.handleLog(level: .deinit, message: message, shouldLogContext: shouldLogContext, context: context)
5555
}
5656
}

Sources/LogKit/LogKit.swift renamed to Sources/LoggerKit/LoggerKit.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
//
2-
// LogKit.swift
2+
// LoggerKit.swift
33
//
44
//
55
// Created by Vishweshwaran on 01/08/22.
66
//
77

88
import Foundation
99

10-
public enum Log: Loggable {
10+
public enum Logger: Loggable {
1111

1212
enum LogLevel {
1313

Tests/LogKitTests/LogKitTests.swift

Lines changed: 0 additions & 81 deletions
This file was deleted.
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
import XCTest
2+
@testable import LoggerKit
3+
4+
final class LogKitTests: XCTestCase {
5+
6+
func testInitLog() {
7+
Logger.initialize("LogKitTest Init")
8+
}
9+
10+
func testVerboseLog() {
11+
Logger.verbose("Example of verbose log.")
12+
}
13+
14+
func testInfoLog() {
15+
Logger.info("Something went wrong.")
16+
}
17+
18+
func testDebugLog() {
19+
Logger.debug("Debug mode enabled")
20+
}
21+
22+
func testWarningLog() {
23+
Logger.warning("Warning, duplication warning.")
24+
}
25+
26+
func testErrorLog() {
27+
Logger.error("Error, data didn't fetch properly.")
28+
}
29+
30+
func testWithVariables() {
31+
let intTest: Int = 01
32+
let floatTest: Float = 30.01
33+
let doubleTest: Double = 30.0001
34+
let stringTest: String = "StringTest"
35+
36+
Logger.error(intTest)
37+
Logger.info(floatTest)
38+
Logger.warning(doubleTest)
39+
Logger.debug(stringTest)
40+
}
41+
42+
func testLogWithParameter() {
43+
let errorMessage: String = "Dependency Error."
44+
45+
Logger.error("Something went wrong! \(errorMessage)")
46+
Logger.info("Something went wrong! \(errorMessage)")
47+
Logger.debug("Something went wrong! \(errorMessage)")
48+
Logger.warning("Something went wrong! \(errorMessage)")
49+
Logger.verbose("Something went wrong! \(errorMessage)")
50+
}
51+
52+
func testLogWithoutParameter() {
53+
Logger.error()
54+
Logger.info()
55+
Logger.debug()
56+
Logger.warning()
57+
Logger.verbose()
58+
}
59+
60+
func testWithComplexObjects() {
61+
62+
struct LogTest {
63+
var id: Int
64+
var message: String
65+
}
66+
67+
let testObj01 = LogTest(id: 1, message: "Something went wrong")
68+
let testObj02 = LogTest(id: 2, message: "404, Error")
69+
let testObj03 = LogTest(id: 3, message: "200 Status Ok!")
70+
71+
Logger.error(testObj01, testObj02, testObj03)
72+
Logger.info(testObj01, testObj02, testObj03)
73+
Logger.debug(testObj01, testObj02, testObj03)
74+
Logger.warning(testObj01, testObj02, testObj03)
75+
Logger.verbose(testObj01, testObj02, testObj03)
76+
}
77+
78+
func testDeinitLog() {
79+
Logger.teardown("LogKitTest deinit")
80+
}
81+
}

0 commit comments

Comments
 (0)