debug.go 730 B

1234567891011121314151617181920212223242526272829
  1. // Copyright (C) 2015 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 fs
  7. import (
  8. "os"
  9. "strings"
  10. "github.com/syncthing/syncthing/lib/logger"
  11. )
  12. var (
  13. l = logger.DefaultLogger.NewFacility("fs", "Filesystem access")
  14. )
  15. func init() {
  16. logger.DefaultLogger.NewFacility("walkfs", "Filesystem access while walking")
  17. switch {
  18. case strings.Contains(os.Getenv("STTRACE"), "walkfs") || os.Getenv("STTRACE") == "all":
  19. l.SetDebug("walkfs", true)
  20. fallthrough
  21. case strings.Contains(os.Getenv("STTRACE"), "fs"):
  22. l.SetDebug("fs", true)
  23. }
  24. }