Command line client for Write.as https://write.as/apps/cli
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
828 B

  1. package log
  2. import (
  3. "fmt"
  4. "os"
  5. cli "gopkg.in/urfave/cli.v1"
  6. )
  7. // Info logs general diagnostic messages, shown only when the -v or --verbose
  8. // flag is provided.
  9. func Info(c *cli.Context, s string, p ...interface{}) {
  10. if c.Bool("v") || c.Bool("verbose") || c.GlobalBool("v") || c.GlobalBool("verbose") {
  11. fmt.Fprintf(os.Stderr, s+"\n", p...)
  12. }
  13. }
  14. // InfolnQuit logs the message to stderr and exits normally (without an error).
  15. func InfolnQuit(s string, p ...interface{}) {
  16. fmt.Fprintf(os.Stderr, s+"\n", p...)
  17. os.Exit(0)
  18. }
  19. // Errorln logs the message to stderr
  20. func Errorln(s string, p ...interface{}) {
  21. fmt.Fprintf(os.Stderr, s+"\n", p...)
  22. }
  23. // ErrorlnQuit logs the message to stderr and exits with an error code.
  24. func ErrorlnQuit(s string, p ...interface{}) {
  25. fmt.Fprintf(os.Stderr, s+"\n", p...)
  26. os.Exit(1)
  27. }