We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Logger Cleanup

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.

Assignment

Clean up logger resources before exit.

  1. type closeFunc func() error
    
    func initializeLogger(logFile string) (*log.Logger, closeFunc, error)
    
  2. 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.