Go Package log: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 13: Line 13:
=Elements=
=Elements=


* <tt>[https://golang.org/pkg/log/#Fatal log.Fatal]</tt>
* <tt>[https://golang.org/pkg/log/#Fatal log.Fatal]</tt>: <tt>Fatal</tt> is equivalent to <tt>Print()</tt> followed by a call to <tt>os.Exit(1)</tt>.


=Recipes=
=Recipes=

Revision as of 18:53, 2 April 2016

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)
}