@@ -131,18 +131,20 @@ public final class NKLogFileManager {
131131 /// - message: The log message content.
132132 public func writeLog( tag: String , typeTag: NKLogTypeTag , message: String ) {
133133 guard !tag. isEmpty else { return }
134- let emojiColored = emojiColored ( typeTag. rawValue)
135134
136- writeLog ( " \( emojiColored) [ \( tag. uppercased ( ) ) ] \( message) " )
135+ let taggedMessage = " [ \( tag. uppercased ( ) ) ] \( message) "
136+ writeLog ( taggedMessage, typeTag: typeTag)
137137 }
138138
139- /// Writes a log message to both the console and the log file .
139+ /// Writes a log message with an optional typeTag to determine console emoji .
140140 /// Emojis and keyword replacements (e.g. [SUCCESS] -> 🟢) are only applied to the console output.
141- /// The log file is plain and suitable for parsing. Rotation is handled before writing .
141+ /// The file output remains clean (no emoji or substitutions) .
142142 ///
143- /// - Parameter message: The log message to record.
144- public func writeLog( _ message: String ? ) {
145- guard logLevel != . disabled, let message = message else { return }
143+ /// - Parameters:
144+ /// - message: The log message to record.
145+ /// - typeTag: Optional log type tag to determine console emoji (e.g. [INFO], [ERROR]).
146+ public func writeLog( _ message: String , typeTag: NKLogTypeTag ? = nil ) {
147+ guard logLevel != . disabled else { return }
146148
147149 // Generate timestamps for file and console
148150 let fileTimestamp = Self . stableTimestampString ( )
@@ -151,21 +153,21 @@ public final class NKLogFileManager {
151153 // Prepare the clean file line (without emojis or replacements)
152154 let fileLine = " \( fileTimestamp) \( message) \n "
153155
154- // Prepare the console line with emoji prefix and keyword substitution
155- let emojiPrefix = emojiColored ( message)
156+ // Determine emoji only if a typeTag is provided
157+ let emojiPrefix = typeTag. map { emojiColored ( $0. rawValue) } ?? " "
158+
159+ // Apply keyword replacements (e.g. [SUCCESS] -> 🟢) only in console
156160 let visualMessage = message
157- . replacingOccurrences ( of: " RESPONSE: SUCCESS" , with: " 🟢 " )
158- . replacingOccurrences ( of: " RESPONSE: ERROR" , with: " 🔴 " )
161+ . replacingOccurrences ( of: " [ SUCCESS] " , with: " 🟢 " )
162+ . replacingOccurrences ( of: " [ ERROR] " , with: " 🔴 " )
159163
160164 let consoleLine = " [NKLOG] [ \( consoleTimestamp) ] \( emojiPrefix) \( visualMessage) "
161165 print ( consoleLine)
162166
163- // Ensure log rotation is completed before writing to the file
164167 rotationQueue. sync {
165168 self . checkForRotation ( )
166169 }
167170
168- // Write to the log file asynchronously
169171 logQueue. async {
170172 self . appendToLog ( fileLine)
171173 }
0 commit comments