Golang logging: Difference between revisions

From wikinotes
No edit summary
No edit summary
Line 1: Line 1:
Logging is a standardized format of writing progress/debug info.
Logging is a standardized format of writing progress/debug info.
= Documentation =
<blockquote>
{| class="wikitable"
|-
| <code>log</code> || https://pkg.go.dev/log
|-
| logfmt flags || https://pkg.go.dev/log#pkg-constants
|-
|}
</blockquote><!-- Documentation -->


= Example =
= Example =

Revision as of 21:35, 18 June 2022

Logging is a standardized format of writing progress/debug info.

Documentation

log https://pkg.go.dev/log
logfmt flags https://pkg.go.dev/log#pkg-constants

Example

import "os"
import "log"

// params:
//   1. device you'd like to log to
//   2. log-prefix of this logger
//   3. log-formatting options
//
var Logger = log.New(os.Stderr, "", log.Ldate|log.Ltime|log.Lshortfile)

func main() {
    Logger.Println("this is a test")
}