Skip to content
This repository has been archived by the owner on Mar 24, 2023. It is now read-only.

Commit

Permalink
Copy editing
Browse files Browse the repository at this point in the history
  • Loading branch information
mattt committed Mar 26, 2020
1 parent 4105748 commit 95d3aa4
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions 2020-03-26-swift-log.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
<a href="https://en.wikipedia.org/wiki/PCI_DSS">
<abbr title="Payment Card Industry Data Security Standard">PCI</abbr>
</a>
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 95d3aa4

Please sign in to comment.