{"_id":"5676d59a12ea5a2300726aba","version":{"_id":"5672fc989996590d00c22c68","__v":7,"project":"5672fc989996590d00c22c65","createdAt":"2015-12-17T18:19:04.699Z","releaseDate":"2015-12-17T18:19:04.699Z","categories":["5672fc999996590d00c22c69","567301169d4c060d009da8b3","56730183547bee0d00997d1a","5673018a06b19d0d0010691b","567301b53054630d00fe9288","567400638565060d009a86fb","5674017bf79ca90d00ad2f67"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"2.5.0","version":"2.5.0"},"__v":3,"category":{"_id":"5673018a06b19d0d0010691b","pages":["567302825316790d001f8d6a","5673029345185e0d008bd1c2","5676d59a12ea5a2300726aba"],"project":"5672fc989996590d00c22c65","__v":3,"version":"5672fc989996590d00c22c68","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-12-17T18:40:10.078Z","from_sync":false,"order":4,"slug":"intermediate","title":"Advanced"},"project":"5672fc989996590d00c22c65","user":"5654ea8be0d82b0d00ab5747","updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-12-20T16:21:46.125Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":3,"body":"The built in logging property is a `Logger` which is initialized with a default `LoggerBlockType`. When a message is sent to the log property, this block is executed on queue.\n\nTherefore logging to a 3rd party logger is supported by setting the default logger block. In addition to the message to log, the block also receives the severity, the file path, function and line number. Therefore it is should be possible to any 3rd party logger.\n\nAs an example, here we will show integration with [SwiftyBeaver](https://github.com/SwiftyBeaver/SwiftyBeaver), which is taken from the Permissions example project. \n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"import Operations\\nimport SwiftyBeaver\\n\\n// This is following SwiftBeaver's example\\nlet log = SwiftyBeaver.self\\n\\n:::at:::UIApplicationMain\\nclass AppDelegate: UIResponder, UIApplicationDelegate {\\n\\n    var window: UIWindow?\\n\\n    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {\\n\\n        // Set up Logging with SwiftyBeaver\\n        let console = ConsoleDestination()\\n        log.addDestination(console)\\n\\n        LogManager.logger = { message, severity, file, function, line in\\n            switch severity {\\n            case .Verbose:\\n                log.verbose(message, file, function, line: line)\\n            case .Notice:\\n                log.debug(message, file, function, line: line)\\n            case .Info:\\n                log.info(message, file, function, line: line)\\n            case .Warning:\\n                log.warning(message, file, function, line: line)\\n            case .Fatal:\\n                log.error(message, file, function, line: line)\\n            }\\n        }\\n        \\n        LogManager.severity = .Info\\n\\n        return true\\n    }\\n}\\n\",\n      \"language\": \"swift\",\n      \"name\": \"AppDelegate with custom logging\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"custom-logging","type":"basic","title":"Custom Logging"}
The built in logging property is a `Logger` which is initialized with a default `LoggerBlockType`. When a message is sent to the log property, this block is executed on queue. Therefore logging to a 3rd party logger is supported by setting the default logger block. In addition to the message to log, the block also receives the severity, the file path, function and line number. Therefore it is should be possible to any 3rd party logger. As an example, here we will show integration with [SwiftyBeaver](https://github.com/SwiftyBeaver/SwiftyBeaver), which is taken from the Permissions example project. [block:code] { "codes": [ { "code": "import Operations\nimport SwiftyBeaver\n\n// This is following SwiftBeaver's example\nlet log = SwiftyBeaver.self\n\n@UIApplicationMain\nclass AppDelegate: UIResponder, UIApplicationDelegate {\n\n var window: UIWindow?\n\n func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {\n\n // Set up Logging with SwiftyBeaver\n let console = ConsoleDestination()\n log.addDestination(console)\n\n LogManager.logger = { message, severity, file, function, line in\n switch severity {\n case .Verbose:\n log.verbose(message, file, function, line: line)\n case .Notice:\n log.debug(message, file, function, line: line)\n case .Info:\n log.info(message, file, function, line: line)\n case .Warning:\n log.warning(message, file, function, line: line)\n case .Fatal:\n log.error(message, file, function, line: line)\n }\n }\n \n LogManager.severity = .Info\n\n return true\n }\n}\n", "language": "swift", "name": "AppDelegate with custom logging" } ] } [/block]