profiler.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import warnings
  2. from ..middleware.profiler import * # noqa: F401, F403
  3. warnings.warn(
  4. "'werkzeug.contrib.profiler' has moved to"
  5. "'werkzeug.middleware.profiler'. This import is deprecated as of"
  6. "version 0.15 and will be removed in version 1.0.",
  7. DeprecationWarning,
  8. stacklevel=2,
  9. )
  10. class MergeStream(object):
  11. """An object that redirects ``write`` calls to multiple streams.
  12. Use this to log to both ``sys.stdout`` and a file::
  13. f = open('profiler.log', 'w')
  14. stream = MergeStream(sys.stdout, f)
  15. profiler = ProfilerMiddleware(app, stream)
  16. .. deprecated:: 0.15
  17. Use the ``tee`` command in your terminal instead. This class
  18. will be removed in 1.0.
  19. """
  20. def __init__(self, *streams):
  21. warnings.warn(
  22. "'MergeStream' is deprecated as of version 0.15 and will be removed in"
  23. " version 1.0. Use your terminal's 'tee' command instead.",
  24. DeprecationWarning,
  25. stacklevel=2,
  26. )
  27. if not streams:
  28. raise TypeError("At least one stream must be given.")
  29. self.streams = streams
  30. def write(self, data):
  31. for stream in self.streams:
  32. stream.write(data)