Documentation ¶
Index ¶
- Variables
- func Debug(format string, v ...interface{})
- func DebugRequest(req *http.Request, res *http.Response)
- func Init(errorOutput io.Writer, debugOutput io.Writer)
- func LoggerToFile(filename string, locateWithExec bool, maxSize, maxBackups, maxAge int, ...) (output io.WriteCloser, cause error)
- type Error
- type Result
- type ResultCode
Constants ¶
This section is empty.
Variables ¶
SuccessResult is a default success result
Functions ¶
func Debug ¶
func Debug(format string, v ...interface{})
Debug formats with fmt.Sprintf and prints the result to the configured writer
func DebugRequest ¶
DebugRequest will dump the given request and response and prints the result to the configured writer
func Init ¶
Init initialises the error and debug output loggers
func LoggerToFile ¶
func LoggerToFile(filename string, locateWithExec bool, maxSize, maxBackups, maxAge int, compressBackups bool) ( output io.WriteCloser, cause error)
LoggerToFile creates qn output file destination for logging which can then be passed to an Init call. filename is the file to write logs to locateWithExec prepends the executable directory to the filename when true maxSize is the maximum size in megabytes of the log file before it gets rotated maxAge is the maximum number of days to retain old log files maxBackups is the maximum number of old log files to retain compressBackups determines if the rotated log files should be compressed using gzip
Types ¶
type Error ¶
Error is used to provide information about a program error and facilitate debugging
func NewError ¶
NewError creates a new Error struct with the given parameters
type Result ¶
type Result struct { Code ResultCode Error *Error }
Result couples a result code with an error, which should only be nil when the code is SUCCESS.
func NewResult ¶
func NewResult(code ResultCode, error *Error) Result
NewResult creates a new Result struct with the given parameters
func ResultFromCause ¶
ResultFromCause creates a Result based on the given parameters
func ResultFromCode ¶
func ResultFromCode(code ResultCode, message string) Result
ResultFromCode creates a Result based on the given parameters
func ResultFromError ¶
ResultFromError creates a Result based on the given parameters
func ResultFromMessage ¶
ResultFromMessage creates a Result based on the given parameters
func (Result) Description ¶
Description returns just the messages for for error and cause, without the debug information.
func (Result) Failure ¶
Failure will return true if the result indicates failure
type ResultCode ¶
type ResultCode int
ResultCode is a predefined code to describe the result of a function call.
const ( // Success result Success ResultCode = 100 // ErrorGeneric result ErrorGeneric ResultCode = 200 // BadRequest result ErrorBadRequest ResultCode = 400 // TokenInactive result ErrorTokenInactive ResultCode = 455 )