Go Package log: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
No edit summary
Line 4: Line 4:


=Internal=
=Internal=
 
* [[Go_Logging#Standard_Library_log_Package|Go Logging]]
* [[Go_Language_Modularization#log|Standard Library]]
* [[Go_Language_Modularization#log|Standard Library]]



Revision as of 19:56, 15 December 2023

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