{"action":"created","issue":{"url":"https://api.github.com/repos/CocoaLumberjack/CocoaLumberjack/issues/952","repository_url":"https://api.github.com/repos/CocoaLumberjack/CocoaLumberjack","labels_url":"https://api.github.com/repos/CocoaLumberjack/CocoaLumberjack/issues/952/labels{/name}","comments_url":"https://api.github.com/repos/CocoaLumberjack/CocoaLumberjack/issues/952/comments","events_url":"https://api.github.com/repos/CocoaLumberjack/CocoaLumberjack/issues/952/events","html_url":"https://github.com/CocoaLumberjack/CocoaLumberjack/pull/952","id":367095296,"node_id":"MDExOlB1bGxSZXF1ZXN0MjIwNjEyMDk4","number":952,"title":"Use static const for default log level so Swift can strip strings","user":{"login":"ffried","id":1689782,"node_id":"MDQ6VXNlcjE2ODk3ODI=","avatar_url":"https://avatars0.githubusercontent.com/u/1689782?v=4","gravatar_id":"","url":"https://api.github.com/users/ffried","html_url":"https://github.com/ffried","followers_url":"https://api.github.com/users/ffried/followers","following_url":"https://api.github.com/users/ffried/following{/other_user}","gists_url":"https://api.github.com/users/ffried/gists{/gist_id}","starred_url":"https://api.github.com/users/ffried/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ffried/subscriptions","organizations_url":"https://api.github.com/users/ffried/orgs","repos_url":"https://api.github.com/users/ffried/repos","events_url":"https://api.github.com/users/ffried/events{/privacy}","received_events_url":"https://api.github.com/users/ffried/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-10-05T07:41:18Z","updated_at":"2018-10-06T13:01:00Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/CocoaLumberjack/CocoaLumberjack/pulls/952","html_url":"https://github.com/CocoaLumberjack/CocoaLumberjack/pull/952","diff_url":"https://github.com/CocoaLumberjack/CocoaLumberjack/pull/952.diff","patch_url":"https://github.com/CocoaLumberjack/CocoaLumberjack/pull/952.patch"},"body":"### New Pull Request Checklist\r\n\r\n* [x] I have read and understood the [CONTRIBUTING guide](https://github.com/CocoaLumberjack/CocoaLumberjack/blob/master/.github/CONTRIBUTING.md)\r\n* [x] I have read the [Documentation](http://cocoadocs.org/docsets/CocoaLumberjack/)\r\n* [x] I have searched for a similar pull request in the [project](https://github.com/CocoaLumberjack/CocoaLumberjack/pulls) and found none\r\n\r\n* [x] I have updated this branch with the latest master to avoid conflicts (via merge from master or rebase)\r\n* [x] I have added the required tests to prove the fix/feature I am adding\r\n* [ ] I have updated the documentation (if necessary)\r\n* [x] I have run the tests and they pass\r\n* [x] I have run the lint and it passes (`pod lib lint`)\r\n\r\nThis merge request fixes / refers to the following issues: #774 \r\n\r\n### Pull Request Description\r\n\r\nAs described in #774, the previous `defaultDebugLevel` was a normal global variable, that could change at any time. Therefor the compiler did not strip strings that were logged with an inaccessible level.\r\nThis changes this by adding `@inlinable` to the Swift log functions (so the compiler is allowed to inline the code) and using a `static const` definition for the default log level. This definition now cannot be changed in Swift code, but needs to be defined either via the `GCC_PREPROCESSOR_DEFINITIONS` build setting, or using a `#define` in a bridging header of a Swift target.\r\n"},"comment":{"url":"https://api.github.com/repos/CocoaLumberjack/CocoaLumberjack/issues/comments/427571926","html_url":"https://github.com/CocoaLumberjack/CocoaLumberjack/pull/952#issuecomment-427571926","issue_url":"https://api.github.com/repos/CocoaLumberjack/CocoaLumberjack/issues/952","id":427571926,"node_id":"MDEyOklzc3VlQ29tbWVudDQyNzU3MTkyNg==","user":{"login":"ffried","id":1689782,"node_id":"MDQ6VXNlcjE2ODk3ODI=","avatar_url":"https://avatars0.githubusercontent.com/u/1689782?v=4","gravatar_id":"","url":"https://api.github.com/users/ffried","html_url":"https://github.com/ffried","followers_url":"https://api.github.com/users/ffried/followers","following_url":"https://api.github.com/users/ffried/following{/other_user}","gists_url":"https://api.github.com/users/ffried/gists{/gist_id}","starred_url":"https://api.github.com/users/ffried/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ffried/subscriptions","organizations_url":"https://api.github.com/users/ffried/orgs","repos_url":"https://api.github.com/users/ffried/repos","events_url":"https://api.github.com/users/ffried/events{/privacy}","received_events_url":"https://api.github.com/users/ffried/received_events","type":"User","site_admin":false},"created_at":"2018-10-06T13:01:00Z","updated_at":"2018-10-06T13:01:00Z","author_association":"CONTRIBUTOR","body":"To elaborate a bit on how to re-add changing the log level at runtime:\r\nI'd re-add the `defaultDebugLevel` (though probably rename it, since it's not only for _debug_) and add the bitmask-check *after* the bitmask-check of the `static const`. Meaning that if the `static const` is disabling logging for the level of a log message, all bets are off and it's not going to be logged (and in release builds also stripped from the binary). If the `static const` allows the logging of a given message, however, it'll then be checked against the global Swift `var`. And only if both checks succeed, it'll be passed to `DDLog`.\r\nOf course, this also introduces more complexity (e.g. questions like \"why is my verbose log message not logged, I've set `defaultDebugLevel` to `.all`?\" which could happen because `DD_LOG_LEVEL` is set to `DDLogLevelWarning`). On the other hand if we also make the default `.all` for `defaultDebugLevel`, this should only happen if both `defaultDebugLevel` *and* `DD_LOG_LEVEL` have already been changed. And at that point I'd expect the developer to know that."}}
{"actor":{"display_login":"ffried"}}