common

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package common contains common utilities and functions used by the service.

Index

Constants

This section is empty.

Variables

View Source
var (
	Version    = "dev"
	ShellToUse = GetEnv("SHELL_TO_USE", "/bin/ash")
)

Functions

func GetEnv added in v0.5.0

func GetEnv(key, defaultValue string) string

GetEnv returns the value of the environment variable named by key, or defaultValue if the environment variable doesn't exist

func GetEnvInt

func GetEnvInt(key string, defaultValue int) int

GetEnvInt returns the value of the environment variable named by key, or defaultValue if the environment variable doesn't exist or is not a valid integer

func SetupLogger

func SetupLogger(opts *LoggingOpts) (log *httplog.Logger)

func Shellout added in v0.5.0

func Shellout(command string) (string, string, error)

Types

type LoggingOpts

type LoggingOpts struct {
	ServiceName string

	// Whether to log in JSON format
	JSON bool

	// Whether to log debug messages
	Debug bool

	// Concise mode includes fewer log details during the request flow. For example excluding details like
	// request content length, user-agent and other details. This is useful if during development your console is too noisy.
	Concise bool

	// RequestHeaders enables logging of all request headers, however sensitive headers like authorization, cookie and set-cookie are hidden.
	RequestHeaders bool

	// Tags are additional fields included at the root level of all logs. These can be useful for example the commit hash of a build, or an environment name like prod/stg/dev
	Tags map[string]string
}

Jump to

Keyboard shortcuts

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