Documentation ¶
Overview ¶
Package msg provides common message functions.
Index ¶
- Variables
- func FatalInfoOnErr(err error, info string)
- func FatalInfoOnFalse(flag bool, info string)
- func FatalInfoOnTrue(flag bool, info string)
- func FatalOnErr(err error)
- func FatalOnFalse(flag bool)
- func FatalOnTrue(flag bool)
- func Info(info string)
- func InfoOnErr(err error, info string)
- func InfoOnFalse(flag bool, info string)
- func InfoOnTrue(flag bool, info string)
- func OnErr(err error)
- func OnErrF(w io.Writer, err error)
- func OnErrFv(w io.Writer, err error) error
- func OnFalse(flag bool)
- func OnTrue(flag bool)
- func OsExitAllow(o OrigLogFatalf)
- func Tell(w io.Writer, info string)
- type OrigLogFatalf
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var Verbose bool
Functions ¶
func FatalInfoOnErr ¶
FatalInfoOnErr ends in osExit(1) if err not nil.
Example ¶
package main import ( "github.com/rokath/trice/pkg/msg" ) func main() { var e error msg.FatalInfoOnErr(e, "just in case") }
Output:
func FatalInfoOnFalse ¶ added in v0.26.0
FatalInfoOnFalse prints info and a common error message with location info when err is not nil.
Example ¶
package main import ( "github.com/rokath/trice/pkg/msg" ) func main() { msg.FatalInfoOnFalse(true, "just in case") }
Output:
func FatalInfoOnTrue ¶ added in v0.26.0
FatalInfoOnTrue prints info and a common error message with location info when err is not nil.
Example ¶
package main import ( "github.com/rokath/trice/pkg/msg" ) func main() { msg.FatalInfoOnTrue(false, "just in case") }
Output:
func FatalOnErr ¶
func FatalOnErr(err error)
FatalOnErr ends in osExit(1) if err not nil.
Example ¶
package main import ( "log" "github.com/rokath/trice/pkg/msg" ) func main() { log.SetFlags(0) var e error msg.FatalOnErr(e) }
Output:
func FatalOnFalse ¶
func FatalOnFalse(flag bool)
FatalOnFalse ends in osExit(1) if flag is false.
Example ¶
package main import ( "github.com/rokath/trice/pkg/msg" ) func main() { msg.FatalOnFalse(true) }
Output:
func FatalOnTrue ¶
func FatalOnTrue(flag bool)
FatalOnTrue ends in osExit(1) if flag is true.
Example ¶
package main import ( "github.com/rokath/trice/pkg/msg" ) func main() { msg.FatalOnTrue(false) }
Output:
func Info ¶
func Info(info string)
Info prints info with location info.
Example ¶
package main import ( "github.com/rokath/trice/pkg/msg" ) func main() { msg.Info("code issue") }
Output: Error in msg_blackbox_test.go:14: func 'github.com/rokath/trice/pkg/msg_test.ExampleInfo' -> code issue
func InfoOnErr ¶
InfoOnErr prints info and a common error message with location info when err is not nil.
Example ¶
package main import ( "errors" "github.com/rokath/trice/pkg/msg" ) func main() { var e error msg.InfoOnErr(e, "just in case") e = errors.New("s.th. went wrong") msg.InfoOnErr(e, "just in case") }
Output: just in case Error in msg_blackbox_test.go:39: func 'github.com/rokath/trice/pkg/msg_test.ExampleInfoOnErr' -> s.th. went wrong
func InfoOnFalse ¶
InfoOnFalse prints info and a common error message with location info when flag is false.
Example ¶
package main import ( "github.com/rokath/trice/pkg/msg" ) func main() { msg.InfoOnFalse(true, "just in case") msg.InfoOnFalse(false, "just in case") }
Output: Error in msg_blackbox_test.go:89: func 'github.com/rokath/trice/pkg/msg_test.ExampleInfoOnFalse' -> just in case
func InfoOnTrue ¶
InfoOnTrue prints info and a common error message with location info when flag is true.
Example ¶
package main import ( "github.com/rokath/trice/pkg/msg" ) func main() { msg.InfoOnTrue(false, "just in case") msg.InfoOnTrue(true, "just in case") }
Output: Error in msg_blackbox_test.go:65: func 'github.com/rokath/trice/pkg/msg_test.ExampleInfoOnTrue' -> just in case
func OnErr ¶
func OnErr(err error)
OnErr prints info and a common error message with location info when err is not nil.
Example ¶
package main import ( "errors" "github.com/rokath/trice/pkg/msg" ) func main() { var e error msg.OnErr(e) e = errors.New("s.th. went wrong") msg.OnErr(e) }
Output: Error in msg_blackbox_test.go:23: func 'github.com/rokath/trice/pkg/msg_test.ExampleOnErr' -> s.th. went wrong
func OnErrF ¶ added in v0.44.0
OnErrF prints info and a common error message with location info when err is not nil.
func OnErrFv ¶ added in v0.70.0
OnErrFv prints info and a common error message with location info when err is not nil.
func OnFalse ¶
func OnFalse(flag bool)
OnFalse prints info and a common error message with location info when flag is false.
Example ¶
package main import ( "github.com/rokath/trice/pkg/msg" ) func main() { msg.OnFalse(true) msg.OnFalse(false) }
Output: Error in msg_blackbox_test.go:77: func 'github.com/rokath/trice/pkg/msg_test.ExampleOnFalse' -> <nil>
func OnTrue ¶
func OnTrue(flag bool)
OnTrue prints info and a common error message with location info when flag is true.
Example ¶
package main import ( "github.com/rokath/trice/pkg/msg" ) func main() { msg.OnTrue(false) msg.OnTrue(true) }
Output: Error in msg_blackbox_test.go:53: func 'github.com/rokath/trice/pkg/msg_test.ExampleOnTrue' -> <nil>
func OsExitAllow ¶ added in v0.29.2
func OsExitAllow(o OrigLogFatalf)
OsExitAllow place the original fatal function back
Types ¶
type OrigLogFatalf ¶ added in v0.49.0
type OrigLogFatalf func(format string, v ...interface{})
func OsExitDisallow ¶ added in v0.29.2
func OsExitDisallow() (o OrigLogFatalf)
OsExitDisallow replace the original fatal function