Go Package log

From NovaOrdis Knowledge Base
Revision as of 22:14, 6 September 2023 by Ovidiu (talk | contribs)
Jump to navigation Jump to search

External

Internal

Overview

The "log" package provides support for logging messages to stdout, stderr or custom devices.

Elements

  • log.Fatal: Fatal is equivalent to Print() followed by a call to os.Exit(1).

Recipes

Changing the Logging Device

By default, the logger is set to write to stderr. To change that:

import (
    "log"
    "os"
)
...
func init() {

    // change the device for logging to stdout
    log.SetOutput(os.Stdout)
}