0001 /** 0002 * Copyright IBM Corporation 2015 0003 * 0004 * Licensed under the Apache License, Version 2.0 (the "License"); 0005 * you may not use this file except in compliance with the License. 0006 * You may obtain a copy of the License at 0007 * 0008 * http://www.apache.org/licenses/LICENSE-2.0 0009 * 0010 * Unless required by applicable law or agreed to in writing, software 0011 * distributed under the License is distributed on an "AS IS" BASIS, 0012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 0013 * See the License for the specific language governing permissions and 0014 * limitations under the License. 0015 **/ 0016 0017 import LoggerAPI 0018 0019 public enum TerminalColor: String { 0020 case White = "\u{001B}[0;37m" // white 0021 case Red
HeliumLogger.swift:48 var color : TerminalColor = .ForegroundHeliumLogger.swift:59 print ("\(color.rawValue) \(type.rawValue): \(functionName) \(fileName) line \(lineNum) - \(msg) \(TerminalColor.Foreground.rawValue)")HeliumLogger.swift:63 print ("\(color.rawValue) \(type.rawValue): \(msg) \(TerminalColor.White.rawValue)")= "\u{001B}[0;31m" // red 0022 case Yellow
HeliumLogger.swift:53 color = .Red= "\u{001B}[0;33m" // yellow 0023 case Foreground
HeliumLogger.swift:51 color = .Yellow= "\u{001B}[0;39m" // default foreground color 0024 case Background = "\u{001B}[0;49m" // default background color 0025 } 0026 0027 public class HeliumLogger
HeliumLogger.swift:48 var color : TerminalColor = .ForegroundHeliumLogger.swift:55 color = .Foreground{ 0028 0029 /// 0030 /// Singleton instance of the logger 0031 // static public var logger: Logger? 0032 0033 public var colored
HeliumLogger.swift:43 extension HeliumLogger : Logger {: Bool = true 0034 0035 public var details
HeliumLogger.swift:58 if colored && details {HeliumLogger.swift:60 } else if !colored && details {HeliumLogger.swift:62 } else if colored && !details {: Bool = true 0036 0037 public init () {} 0038 0039 0040 0041 } 0042 0043 extension HeliumLogger : Logger { 0044 0045 public func log(type: LoggerMessageType, msg: String, 0046 functionName: String, lineNum: Int, fileName: String ) { 0047 0048 var color : TerminalColor = .Foreground 0049 0050 if type == .Warning { 0051 color = .Yellow 0052 } else if type == .Error { 0053 color = .Red 0054 } else { 0055 color = .Foreground 0056 } 0057 0058 if colored && details { 0059 print ("\(color.rawValue) \(type.rawValue): \(functionName) \(fileName) line \(lineNum) - \(msg) \(TerminalColor.Foreground.rawValue)") 0060 } else if !colored && details { 0061 print (" \(type.rawValue): \(functionName) \(fileName) line \(lineNum) - \(msg)") 0062 } else if colored && !details { 0063 print ("\(color.rawValue) \(type.rawValue): \(msg) \(TerminalColor.White.rawValue)") 0064 } else { 0065 print (" \(type.rawValue): \(msg)") 0066 } 0067 0068 } 0069 } 0070
HeliumLogger.swift:58 if colored && details {HeliumLogger.swift:60 } else if !colored && details {HeliumLogger.swift:62 } else if colored && !details {