log_collector.go 879 B

1234567891011121314151617181920212223242526272829303132333435
  1. package diagnostic
  2. import (
  3. "context"
  4. )
  5. // Represents the path of the log file or log directory.
  6. // This struct is meant to give some ergonimics regarding
  7. // the logging information.
  8. type LogInformation struct {
  9. path string // path to a file or directory
  10. wasCreated bool // denotes if `path` was created
  11. isDirectory bool // denotes if `path` is a directory
  12. }
  13. func NewLogInformation(
  14. path string,
  15. wasCreated bool,
  16. isDirectory bool,
  17. ) *LogInformation {
  18. return &LogInformation{
  19. path,
  20. wasCreated,
  21. isDirectory,
  22. }
  23. }
  24. type LogCollector interface {
  25. // This function is responsible for returning a path to a single file
  26. // whose contents are the logs of a cloudflared instance.
  27. // A new file may be create by a LogCollector, thus, its the caller
  28. // responsibility to remove the newly create file.
  29. Collect(ctx context.Context) (*LogInformation, error)
  30. }