diff --git a/gunicorn/glogging.py b/gunicorn/glogging.py index eaa82708..d15925fd 100644 --- a/gunicorn/glogging.py +++ b/gunicorn/glogging.py @@ -87,6 +87,9 @@ class LazyWriter(object): def flush(self): self.open().flush() + def isatty(self): + return bool(self.fileobj and self.fileobj.isatty()) + class SafeAtoms(dict): def __init__(self, atoms): diff --git a/tests/test_005-lazywriter-isatty.py b/tests/test_005-lazywriter-isatty.py new file mode 100644 index 00000000..50cc71c9 --- /dev/null +++ b/tests/test_005-lazywriter-isatty.py @@ -0,0 +1,13 @@ +import sys + +from gunicorn.glogging import LazyWriter + + +def test_lazywriter_isatty(): + orig = sys.stdout + sys.stdout = LazyWriter('test.log') + try: + sys.stdout.isatty() + except AttributeError: + raise AssertionError("LazyWriter has no attribute 'isatty'") + sys.stdout = orig