Skip to content

Commit ebbc525

Browse files
committed
explain when to pair bootstrap with task-local
1 parent b221b81 commit ebbc525

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

Sources/Logging/Docs.docc/BestPractices/003-AcceptingLoggers.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,12 @@ final class MyLibrary {
144144
}
145145
```
146146

147-
``Logger/init(label:)`` is for the application — typically at `@main`, paired with
148-
``LoggingSystem/bootstrap(_:)``. Library code, including internal application modules,
149-
should not construct loggers.
147+
``Logger/init(label:)`` is for the application — typically at `@main` paired with `.withLogger()`.
148+
Library code, including internal application modules, should not construct loggers.
149+
If they do, setting up the global factory with ``LoggingSystem/bootstrap(_:)`` allows
150+
enforcing a specific factory on all the loggers constructed in the process. This
151+
does not necessary need to be the same factory as was used to create the task-local
152+
logger.
150153

151154
#### Avoid: Relying on ``Logger/current`` across non-Task boundaries
152155

0 commit comments

Comments
 (0)