##// END OF EJS Templates
tracing: extract tracing-active logic to separate function...
Augie Fackler -
r42676:d0b8a3cf default
parent child Browse files
Show More
@@ -13,19 +13,23 b' import os'
13 _pipe = None
13 _pipe = None
14 _checked = False
14 _checked = False
15
15
16 @contextlib.contextmanager
16 def _isactive():
17 def log(whencefmt, *whenceargs):
18 global _pipe, _session, _checked
17 global _pipe, _session, _checked
19 if _pipe is None:
18 if _pipe is None:
20 if _checked:
19 if _checked:
21 yield
20 return False
22 return
23 _checked = True
21 _checked = True
24 if 'HGCATAPULTSERVERPIPE' not in os.environ:
22 if 'HGCATAPULTSERVERPIPE' not in os.environ:
25 yield
23 return False
26 return
27 _pipe = open(os.environ['HGCATAPULTSERVERPIPE'], 'w', 1)
24 _pipe = open(os.environ['HGCATAPULTSERVERPIPE'], 'w', 1)
28 _session = os.environ.get('HGCATAPULTSESSION', 'none')
25 _session = os.environ.get('HGCATAPULTSESSION', 'none')
26 return True
27
28 @contextlib.contextmanager
29 def log(whencefmt, *whenceargs):
30 if not _isactive():
31 yield
32 return
29 whence = whencefmt % whenceargs
33 whence = whencefmt % whenceargs
30 try:
34 try:
31 # Both writes to the pipe are wrapped in try/except to ignore
35 # Both writes to the pipe are wrapped in try/except to ignore
General Comments 0
You need to be logged in to leave comments. Login now