cli

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 19, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Copyright © 2021 Optable Technologies Inc. All rights reserved. See LICENSE for details.

Copyright © 2021 Optable Technologies Inc. All rights reserved. See LICENSE for details.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LevelFromVerbosity

func LevelFromVerbosity(v int) zerolog.Level

LevelFromVerbosity takes a command-line `-v` stackable flag count, e.g. `-vv`, `-vvv` and transforms it into a sensible loglevel. The mapping is:

``:     Warn
`-v`:   Info
`-vv`:  Debug
`-vvv`: Trace

func NewLogger

func NewLogger(cliName string, verbosity int) *zerolog.Logger

Types

type Profiling

type Profiling struct {
	Profiling string `opt:"" hidden:"true" default:""`
}

Profiling is a struct that can be embedded in any kong cli to enable easy and convenient profiling for performance analysis. The flag is hidden from the help message such that we can use it in public cli.

The supported values are:

  • "cpu": Enables CPU profiling.
  • "memory": Enables heap memory profiling.
  • "block": Enables block (contention) profiling.
  • "mutex": Enables mutex profiling.
  • "trace": Enables trace profiling.

The profiling file path will be shown to stderr and can be opened with `go tool pprof $file` or `go tool pprof -http localhost:8080 $file`

In order to enable profiling, one should use the command like this: ``` stopProfiling := cli.Profiling.Start() defer stopProfiling() ```

func (*Profiling) Start

func (p *Profiling) Start() func()

Start starts the profiling operation. It returns a function that needs to be called when the profiling should stop.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL