logging.go 895 B

12345678910111213141516171819202122232425262728293031323334
  1. // Copyright 2018 Twitch Interactive, Inc. All Rights Reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License"). You may not
  4. // use this file except in compliance with the License. A copy of the License is
  5. // located at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // or in the "license" file accompanying this file. This file is distributed on
  10. // an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  11. // express or implied. See the License for the specific language governing
  12. // permissions and limitations under the License.
  13. package gen
  14. import (
  15. "log"
  16. "os"
  17. "strings"
  18. )
  19. // Fail log and exit
  20. func Fail(msgs ...string) {
  21. s := strings.Join(msgs, " ")
  22. log.Print("error:", s)
  23. os.Exit(1)
  24. }
  25. // Error log and exit
  26. func Error(err error, msgs ...string) {
  27. s := strings.Join(msgs, " ") + ":" + err.Error()
  28. log.Print("error:", s)
  29. os.Exit(1)
  30. }