{"action":"created","issue":{"url":"https://api.github.com/repos/IBM-Swift/LoggerAPI/issues/7","repository_url":"https://api.github.com/repos/IBM-Swift/LoggerAPI","labels_url":"https://api.github.com/repos/IBM-Swift/LoggerAPI/issues/7/labels{/name}","comments_url":"https://api.github.com/repos/IBM-Swift/LoggerAPI/issues/7/comments","events_url":"https://api.github.com/repos/IBM-Swift/LoggerAPI/issues/7/events","html_url":"https://github.com/IBM-Swift/LoggerAPI/issues/7","id":153292717,"number":7,"title":"Controller Log Level not supported","user":{"login":"tkhuran","id":18522684,"avatar_url":"https://avatars.githubusercontent.com/u/18522684?v=3","gravatar_id":"","url":"https://api.github.com/users/tkhuran","html_url":"https://github.com/tkhuran","followers_url":"https://api.github.com/users/tkhuran/followers","following_url":"https://api.github.com/users/tkhuran/following{/other_user}","gists_url":"https://api.github.com/users/tkhuran/gists{/gist_id}","starred_url":"https://api.github.com/users/tkhuran/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tkhuran/subscriptions","organizations_url":"https://api.github.com/users/tkhuran/orgs","repos_url":"https://api.github.com/users/tkhuran/repos","events_url":"https://api.github.com/users/tkhuran/events{/privacy}","received_events_url":"https://api.github.com/users/tkhuran/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-05-05T18:26:12Z","updated_at":"2016-06-08T16:23:45Z","closed_at":"2016-06-08T16:23:45Z","body":"LoggerAPI and HeliumLogger currently does not support log level controlling.\r\n\r\nExample:\r\nAn app development life cycle goes from Dev -> Test -> Staging - > Prod. Now chart below shows the log levels for each of the environment that a developer wants to use, staring from Dev (maximum logging) to the Prod with the least logging (only the errors).\r\n\r\n| Environment | Log Levels |\r\n| -------- | -------- |\r\n| DEV   | .Verbose  |\r\n| TEST   | .Debug   |\r\n| STAGE   | .Warning   |\r\n| PROD   | .Error   |\r\n\r\nThe package currently does not support this feature.\r\n\r\n# Proposed changes\r\n\r\n```swift\r\n// Logger.swift\r\npublic enum LoggerMessageType: String {\r\n    case Verbose = \"VERBOSE\"\r\n    case Info = \"INFO\"\r\n    case Debug = \"DEBUG\"\r\n    case Warning = \"WARNING\"\r\n    case Error = \"ERROR\"\r\n    \r\n// added the logger type function\r\n    public func logType() -> Int {\r\n        switch self {\r\n        case .Verbose:\r\n            return 1\r\n        case .Info:\r\n            return 2\r\n        case .Debug:\r\n            return 3\r\n        case .Warning:\r\n            return 4\r\n        case .Error:\r\n            return 5\r\n        }\r\n    }\r\n}\r\n```\r\n\r\n```swift\r\n// Logger.swift\r\npublic class Log {\r\n// your code goes here.\r\npublic class func debug(msg: String, functionName: String = #function,\r\n        lineNum: Int = #line, fileName: String = #file) {\r\n            logger?.log( .Debug, msg: msg,// corrected this line as it was using .Warning\r\n                functionName: functionName, lineNum: lineNum, fileName: fileName)\r\n    }\r\n}\r\n```\r\n\r\n```swift\r\n// HeliumLogger.swift\r\n// added the variable for including LoggerMessageType\r\nprivate var type: LoggerMessageType = .Verbose\r\npublic init (_ type: LoggerMessageType) {\r\n        self.type = type\r\n    }\r\n\r\nextension HeliumLogger : Logger {\r\n// your code goes here\r\nif type.logType() >= self.type.logType() { // controlled logging based on the environment\r\n                if colored {\r\n                    print (\"\\(color.rawValue) \\(message) \\(TerminalColor.Foreground.rawValue)\")\r\n                } else {\r\n                    print (\" \\(message) \")\r\n                }\r\n        }\r\n}\r\n```\r\n\r\n```swift\r\n// example\r\nmain() {\r\nimport LoggerAPI\r\nimport HeliumLogger\r\n// Logging\r\n        Log.logger = HeliumLogger(.Warning)\r\nLog.verbose(\"VERBOSE\")\r\nLog.info(\"INFO\")\r\nLog.debug(\"DEBUG\")\r\nLog.warning(\"WARNING\")\r\nLog.error(\"ERROR\")\r\n}\r\n\r\n// OUTPUT\r\nWARNING\r\nERROR\r\n```"},"comment":{"url":"https://api.github.com/repos/IBM-Swift/LoggerAPI/issues/comments/224645860","html_url":"https://github.com/IBM-Swift/LoggerAPI/issues/7#issuecomment-224645860","issue_url":"https://api.github.com/repos/IBM-Swift/LoggerAPI/issues/7","id":224645860,"user":{"login":"shmuelk","id":16103068,"avatar_url":"https://avatars.githubusercontent.com/u/16103068?v=3","gravatar_id":"","url":"https://api.github.com/users/shmuelk","html_url":"https://github.com/shmuelk","followers_url":"https://api.github.com/users/shmuelk/followers","following_url":"https://api.github.com/users/shmuelk/following{/other_user}","gists_url":"https://api.github.com/users/shmuelk/gists{/gist_id}","starred_url":"https://api.github.com/users/shmuelk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shmuelk/subscriptions","organizations_url":"https://api.github.com/users/shmuelk/orgs","repos_url":"https://api.github.com/users/shmuelk/repos","events_url":"https://api.github.com/users/shmuelk/events{/privacy}","received_events_url":"https://api.github.com/users/shmuelk/received_events","type":"User","site_admin":false},"created_at":"2016-06-08T16:23:45Z","updated_at":"2016-06-08T16:23:45Z","body":"I'm closing this issue. The PR that was merged fixes the problem.\r\n\r\nHaving said that we should look into @kweinmeister's suggestion. We should probably add a description function to the enum that dumps it as a String. See issue IBM-Swift/Kitura#523"}}
{"actor":{"display_login":"shmuelk"}}