

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 6
click for more info
Not enough gems
Cost: 6 gems
1: Logging in Go
incomplete
2: Use the Logger
incomplete
3: Logging Requests
incomplete
4: Global Logger vs. Dependency Injection
incomplete
5: Logger Configuration
incomplete
6: Logger Failure
incomplete
7: Buffered Logging
incomplete
8: Logger Cleanup
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
The buffered writer is faster, but we added a bug! It must be flushed (written to disk) before the program exits, or any pending log messages will be lost!
It's also common to log messages across the network in some scenarios, and those kinds of loggers will also need to be flushed before exit – so we should take that into account in our implementation.
Clean up logger resources before exit.
type closeFunc func() error
func initializeLogger(logFile string) (*log.Logger, closeFunc, error)
Once again, we resort to writing directly to os.Stderr – the logger isn't in a usable state at this point.
LINKO_LOG_FILE=linko.access.log go run .
Run and submit the CLI tests from the root of the Linko repo.