debug.go 750 B

12345678910111213141516171819202122232425262728
  1. // Copyright (C) 2014 The Syncthing Authors.
  2. //
  3. // This Source Code Form is subject to the terms of the Mozilla Public
  4. // License, v. 2.0. If a copy of the MPL was not distributed with this file,
  5. // You can obtain one at https://mozilla.org/MPL/2.0/.
  6. package api
  7. import (
  8. "os"
  9. "strings"
  10. "github.com/syncthing/syncthing/lib/logger"
  11. )
  12. var (
  13. l = logger.DefaultLogger.NewFacility("api", "REST API")
  14. )
  15. func shouldDebugHTTP() bool {
  16. return l.ShouldDebug("api")
  17. }
  18. func init() {
  19. // The debug facility was originally named "http", changed in:
  20. // https://github.com/syncthing/syncthing/pull/5548
  21. l.SetDebug("api", strings.Contains(os.Getenv("STTRACE"), "api") || strings.Contains(os.Getenv("STTRACE"), "http") || os.Getenv("STTRACE") == "all")
  22. }