{"action":"created","issue":{"url":"https://api.github.com/repos/CocoaLumberjack/CocoaLumberjack/issues/663","labels_url":"https://api.github.com/repos/CocoaLumberjack/CocoaLumberjack/issues/663/labels{/name}","comments_url":"https://api.github.com/repos/CocoaLumberjack/CocoaLumberjack/issues/663/comments","events_url":"https://api.github.com/repos/CocoaLumberjack/CocoaLumberjack/issues/663/events","html_url":"https://github.com/CocoaLumberjack/CocoaLumberjack/issues/663","id":119275848,"number":663,"title":"All LogMessages have the same LogLevel when setting defaultDebugLevel","user":{"login":"SlimShady0208","id":949775,"avatar_url":"https://avatars.githubusercontent.com/u/949775?v=3","gravatar_id":"","url":"https://api.github.com/users/SlimShady0208","html_url":"https://github.com/SlimShady0208","followers_url":"https://api.github.com/users/SlimShady0208/followers","following_url":"https://api.github.com/users/SlimShady0208/following{/other_user}","gists_url":"https://api.github.com/users/SlimShady0208/gists{/gist_id}","starred_url":"https://api.github.com/users/SlimShady0208/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SlimShady0208/subscriptions","organizations_url":"https://api.github.com/users/SlimShady0208/orgs","repos_url":"https://api.github.com/users/SlimShady0208/repos","events_url":"https://api.github.com/users/SlimShady0208/events{/privacy}","received_events_url":"https://api.github.com/users/SlimShady0208/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-11-28T07:11:40Z","updated_at":"2015-11-29T08:01:02Z","closed_at":null,"body":"Hello,\r\n\r\nI am currently struggeling with CocoaLumberjack on Swift. I have tried to build a short example of my issue. There is a single view application with a ViewController containing the following code:\r\n\r\n```swift\r\nimport UIKit\r\nimport CocoaLumberjack\r\n\r\nclass ViewController: UIViewController {\r\n\t\r\n\toverride func viewDidLoad() {\r\n\t\tsuper.viewDidLoad()\r\n\t\t\r\n\t\tDDASLLogger.sharedInstance().logFormatter = LogFormatter()\r\n\t\tDDTTYLogger.sharedInstance().logFormatter = LogFormatter()\r\n\t\tDDLog.addLogger(DDASLLogger.sharedInstance())\r\n\t\tDDLog.addLogger(DDTTYLogger.sharedInstance())\r\n\t\t\r\n\t\tdefaultDebugLevel = DDLogLevel.Error     // this property can be changed to any logLevel\r\n\t\t\r\n\t\tDDLogError(\"ERROR\")\r\n\t\tDDLogWarn(\"WARN\")\r\n\t\tDDLogInfo(\"INFO\")\r\n\t\tDDLogDebug(\"DEBUG\")\r\n\t\tDDLogVerbose(\"VERBOSE\")\r\n\t}\r\n}\r\n\r\nclass LogFormatter : NSObject,DDLogFormatter\r\n{\r\n\tfunc formatLogMessage(logMessage: DDLogMessage!) -> String! {\r\n\t\treturn \"[\\(stringForLogLevel(logMessage.level))]: \\(logMessage.message)\"\r\n\t}\r\n\t\r\n\tprivate func stringForLogLevel(logLevel:DDLogLevel) -> String\r\n\t{\r\n\t\tswitch(logLevel)\r\n\t\t{\r\n\t\tcase .Error:\r\n\t\t\treturn \"E\";\r\n\t\tcase .Warning:\r\n\t\t\treturn \"W\";\r\n\t\tcase .Info:\r\n\t\t\treturn \"I\";\r\n\t\tcase .Debug:\r\n\t\t\treturn \"D\";\r\n\t\tcase .Verbose:\r\n\t\t\treturn \"V\";\r\n\t\tdefault:\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\treturn \"\"\r\n\t}\r\n}\r\n```\r\n\r\nSo if I change the `defaultDebugLevel` in the `viewDidLoad`method to every logLevel from `.Error` to `.Verbose` I receive the following console output:\r\n\r\n```\r\n// .Error\r\n[E]: ERROR\r\n```\r\n```\r\n// .Warning\r\n[W]: ERROR\r\n[W]: WARN\r\n```\r\n```\r\n// .Info\r\n[I]: ERROR\r\n[I]: WARN\r\n[I]: INFO\r\n```\r\n```\r\n// .Debug\r\n[D]: ERROR\r\n[D]: WARN\r\n[D]: INFO\r\n[D]: DEBUG\r\n```\r\n```\r\n// .Verbose\r\n[V]: ERROR\r\n[V]: WARN\r\n[V]: INFO\r\n[V]: DEBUG\r\n[V]: VERBOSE\r\n```\r\n\r\nSo it seems to work, that only the LogMessages below the defined `defaultDebugLevel`will be printed. But why do they all have the same logLevel? I did expect an out put like this:\r\n```\r\n// .Verbose\r\n[E]: ERROR\r\n[W]: WARN\r\n[I]: INFO\r\n[D]: DEBUG\r\n[V]: VERBOSE\r\n```"},"comment":{"url":"https://api.github.com/repos/CocoaLumberjack/CocoaLumberjack/issues/comments/160390601","html_url":"https://github.com/CocoaLumberjack/CocoaLumberjack/issues/663#issuecomment-160390601","issue_url":"https://api.github.com/repos/CocoaLumberjack/CocoaLumberjack/issues/663","id":160390601,"user":{"login":"sushichop","id":5669641,"avatar_url":"https://avatars.githubusercontent.com/u/5669641?v=3","gravatar_id":"","url":"https://api.github.com/users/sushichop","html_url":"https://github.com/sushichop","followers_url":"https://api.github.com/users/sushichop/followers","following_url":"https://api.github.com/users/sushichop/following{/other_user}","gists_url":"https://api.github.com/users/sushichop/gists{/gist_id}","starred_url":"https://api.github.com/users/sushichop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sushichop/subscriptions","organizations_url":"https://api.github.com/users/sushichop/orgs","repos_url":"https://api.github.com/users/sushichop/repos","events_url":"https://api.github.com/users/sushichop/events{/privacy}","received_events_url":"https://api.github.com/users/sushichop/received_events","type":"User","site_admin":false},"created_at":"2015-11-29T08:01:02Z","updated_at":"2015-11-29T08:01:02Z","body":"@SlimShady0208 \r\nI think you need to use DDLogFlag instead of DDLogLevel to get the message correctly from \"formatLogMessage\". The sample code is here.\r\n\r\n```swift\r\nclass LogFormatter: NSObject, DDLogFormatter\r\n{\r\n    func formatLogMessage(logMessage: DDLogMessage!) -> String! {\r\n        return \"[\\(stringForLogLevel(logMessage.flag))]: \\(logMessage.message)\"\r\n    }\r\n    \r\n    private func stringForLogLevel(logflag:DDLogFlag) -> String {\r\n        switch(logflag) {\r\n        case DDLogFlag.Error:\r\n            return \"E\"\r\n        case DDLogFlag.Warning:\r\n            return \"W\"\r\n        case DDLogFlag.Info:\r\n            return \"I\"\r\n        case DDLogFlag.Debug:\r\n            return \"D\"\r\n        case DDLogFlag.Verbose:\r\n            return \"V\"\r\n        default:\r\n            break\r\n        }\r\n        return \"\"\r\n    }\r\n}\r\n```\r\n\r\nDDLogFlag is different from DDLogLevel. For example, the flag of Debug is \"0...01000\". On the other hand  the level of Debug is \"0...01111\". \r\nIf you are interesting in it, try to look into [DDLog.h](https://github.com/CocoaLumberjack/CocoaLumberjack/blob/master/Classes/DDLog.h). \r\nAnd [CustomFormatters documentation](https://github.com/CocoaLumberjack/CocoaLumberjack/blob/master/Documentation/CustomFormatters.md) will be helpful for you."}}