-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from aliaslab-1984/develop
BattleAxe channels
- Loading branch information
Showing
17 changed files
with
456 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by Francesco Bianco on 14/05/21. | ||
// | ||
|
||
import Foundation | ||
|
||
/// Helper struct that handles the creation of a printable message, given the message and the needed ingredients. | ||
struct LogMessageFormatter { | ||
|
||
/// Given a log message creates a correclty formatted string following the ingredients provided. | ||
/// - Parameters: | ||
/// - message: The message that needs to be formatted. | ||
/// - ingredients: The ingredients that need to be added to the formatted message. | ||
/// - dateFormatter: The dateformetter style. | ||
/// - Returns: the formatted string. | ||
static func compose(_ message: LogMessage, | ||
using ingredients: [LoggerConfiguration.LogIngredient], | ||
dateFormatter: DateFormatter) -> String { | ||
var finalMessage: String = "" | ||
|
||
ingredients.forEach { ingredient in | ||
switch ingredient { | ||
case .channel: | ||
finalMessage.append("{\(message.channel)} ") | ||
case .severity: | ||
finalMessage.append("[\(message.severity.prettyDescription)] ") | ||
case .date: | ||
finalMessage.append("\(dateFormatter.getCurrentDateAsString()) ") | ||
case .fileName: | ||
finalMessage.append("\(message.callingFilePath):") | ||
case .functionName: | ||
finalMessage.append("\(message.callingStackFrame):") | ||
case .lineNumber: | ||
finalMessage.append("(\(message.callingFileLine))") | ||
case .payload: | ||
finalMessage.append("\(message.payload)") | ||
} | ||
} | ||
|
||
return finalMessage | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.