diff --git a/2020-03-26-swift-log.md b/2020-03-26-swift-log.md index 2229186c..94994911 100644 --- a/2020-03-26-swift-log.md +++ b/2020-03-26-swift-log.md @@ -14,13 +14,12 @@ status: In 2002, the United States Congress enacted the [Sarbanes–Oxley Act](https://en.wikipedia.org/wiki/Sarbanes–Oxley_Act), -which introduced broad oversight to corporations, +which introduced broad oversight to corporations in response to accounting scandals at companies like [Enron](https://en.wikipedia.org/wiki/Enron_scandal) and [MCI WorldCom](https://en.wikipedia.org/wiki/MCI_Inc.#Accounting_scandals) around that time. This act, -along with other regulations like PCI @@ -56,12 +55,12 @@ with distinct log levels and configurable output settings. _Sarbanes–Oxley_ is notable for giving rise to _[Yates v. United States](https://www.oyez.org/cases/2014/13-7451)_: -a delightful Supreme Court case that raised the question of -whether fish (🐟) are considered to be "tangible objects" -for purposes of that statute. +a delightful Supreme Court case that asked the question +_"Are fish (🐟) tangible objects?" Although the Court found in a 5 – 4 decision -that fish are not, _in fact_, "tangible objects", +that fish are _not_, in fact, "tangible objects" +(for purposes of the statute), we remain unconvinced for the same reasons articulated in [Justice Kagan's dissent](https://supreme.justia.com/cases/federal/us/574/528/#tab-opinion-3243031) @@ -119,8 +118,8 @@ from WWDC 2018. As always, an example would be helpful in guiding our discussion. -In the spirit of transparency, -let's imagine writing Swift program +In the spirit of transparency and nostalgia, +let's imagine writing a Swift program that audits the finances of a '00s Fortune 500 company. ```swift @@ -142,8 +141,8 @@ do { } ``` -An `Auditor` type is responsible for polls for changes to a directory -_(an FTP server, for nostalgia's sake)_. +An `Auditor` type polls for changes to a directory +_(an FTP server, because remember: it's 2003)_. Each time a file is added, removed, or changed, its contents are audited for discrepancies. If any financial oddities are encountered, @@ -183,11 +182,9 @@ but it leaves a lot of room for improvement: - For one, our output doesn't have any timestamps associated with it. There's no way to know whether a problem was detected an hour ago or last week. - - Another problem is that our output lacks any coherent structure. At a glance, there's no straightforward way to isolate program noise from real issues. - - Finally, — _and this is mostly due to an under-specified example_ — it's unclear how this output is handled. @@ -204,7 +201,7 @@ by adopting a formal logging infrastructure in your project. ## Adopting SwiftLog in Your Swift Program -Adding `SwiftLog` to an existing Swift package is straightforward. +Adding `SwiftLog` to an existing Swift package is a breeze. You can incorporate it incrementally without making any fundamental changes to your code and have it working in a matter of minutes. @@ -237,7 +234,7 @@ let package = Package( ### Create a Shared, Global Logger `Logger` provides two initializers, -the simplest taking a single `label` parameter: +the simpler of them taking a single `label` parameter: ```swift let logger = Logger(label: "com.NSHipster.Auditor2000") @@ -287,8 +284,8 @@ will default to the specified handler. ### Replacing Print Statements with Logging Statements -Declaring our logger as a top-level constant -allows us to call it anywhere within our module. +Declaring our `logger` as a top-level constant +lets us call it anywhere within our module. Let's revisit our example and spruce it up with our new logger: ```swift