util

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2018 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	//LogDebug logger
	LogDebug *log.Logger
	//LogInfo logger
	LogInfo *log.Logger
	//LogError logger
	LogError *log.Logger

	// DebugLogLevel debug log level
	DebugLogLevel = "debug"
	// InfoLogLevel info log level
	InfoLogLevel = "info"
)

Functions

func CloseLogFile

func CloseLogFile()

CloseLogFile closes the current logFile

func ExecCommandOutput

func ExecCommandOutput(cmd string, args []string) (string, int, error)

ExecCommandOutput returns stdout and stderr in a single string, the return code, and error. If the return code is not zero, error will not be nil. Stdout and Stderr are dumped to the log at the debug level. Return code of 999 indicates an error starting the command.

func FileCheck

func FileCheck(e error)

FileCheck : checks for error

func FileDelete

func FileDelete(path string) error

FileDelete : delete the file

func FileExists

func FileExists(path string) (exists bool, dir bool, err error)

FileExists does a stat on the path and returns true if it exists In addition, dir returns true if the path is a directory

func FileGetStrings

func FileGetStrings(path string) (line []string, err error)

FileGetStrings : get the file contents as array of string

func FileGetStringsWithPattern

func FileGetStringsWithPattern(path string, pattern string) (filelines []string, err error)

FileGetStringsWithPattern : get the filecontents as array of string matching pattern pattern

func FileReadFirstLine

func FileReadFirstLine(path string) (line string, er error)

FileReadFirstLine read first line from a file TODO: make it OS independent

func FileSaveGob

func FileSaveGob(path string, object interface{}) error

FileSaveGob : save the Gob file

func FileWriteString

func FileWriteString(path, line string) (err error)

FileWriteString : write line to the path

func FileWriteStrings

func FileWriteStrings(path string, lines []string) (err error)

FileWriteStrings writes all lines to file specified by path. Newline is appended to each line

func FileloadGob

func FileloadGob(path string, object interface{}) error

FileloadGob : Load and Decode Gob file

func FindStringSubmatchMap

func FindStringSubmatchMap(s string, r *regexp.Regexp) map[string]string

FindStringSubmatchMap : find and build the map of named groups

func HTTPLogger

func HTTPLogger(inner http.Handler, name string) http.Handler

HTTPLogger : wrapper for http logging

func OpenLog

func OpenLog(debug bool) error

OpenLog causes logging to happen to stdout

func OpenLogFile

func OpenLogFile(filePath string, maxSizeMB int, maxFiles int, maxAgeDays int, debug bool) error

OpenLogFile creates a file based logger

Types

This section is empty.

Jump to

Keyboard shortcuts

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