summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Coca <brian.coca+git@gmail.com>2016-01-26 11:22:27 -0500
committerBrian Coca <brian.coca+git@gmail.com>2016-01-26 11:22:52 -0500
commit66104191d182aedd7b76f4a1b839c448f97c3ffe (patch)
treefa27883fdd8a49d1a33ee56a305f29c3464baba9
parent46fde754af5894914faa8d244aaca103355e6a85 (diff)
downloadansible-66104191d182aedd7b76f4a1b839c448f97c3ffe.tar.gz
fixed permissions check for ansible.log
fixes #13990
-rw-r--r--lib/ansible/utils/display.py17
1 files changed, 8 insertions, 9 deletions
diff --git a/lib/ansible/utils/display.py b/lib/ansible/utils/display.py
index 3703c15540..ba92723759 100644
--- a/lib/ansible/utils/display.py
+++ b/lib/ansible/utils/display.py
@@ -48,18 +48,17 @@ except NameError:
# These are module level as we currently fork and serialize the whole process and locks in the objects don't play well with that
debug_lock = Lock()
+logger = None
#TODO: make this a logging callback instead
if C.DEFAULT_LOG_PATH:
path = C.DEFAULT_LOG_PATH
- if (os.path.exists(path) and not os.access(path, os.W_OK)) or not os.access(os.path.dirname(path), os.W_OK):
- print("[WARNING]: log file at %s is not writeable, aborting\n" % path, file=sys.stderr)
-
- logging.basicConfig(filename=path, level=logging.DEBUG, format='%(asctime)s %(name)s %(message)s')
- mypid = str(os.getpid())
- user = getpass.getuser()
- logger = logging.getLogger("p=%s u=%s | " % (mypid, user))
-else:
- logger = None
+ if (os.path.exists(path) and os.access(path, os.W_OK)) or os.access(os.path.dirname(path), os.W_OK):
+ logging.basicConfig(filename=path, level=logging.DEBUG, format='%(asctime)s %(name)s %(message)s')
+ mypid = str(os.getpid())
+ user = getpass.getuser()
+ logger = logging.getLogger("p=%s u=%s | " % (mypid, user))
+ else:
+ print("[WARNING]: log file at %s is not writeable and we cannot create it, aborting\n" % path, file=sys.stderr)
class Display: