##// 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 13 _pipe = None
14 14 _checked = False
15 15
16 @contextlib.contextmanager
17 def log(whencefmt, *whenceargs):
16 def _isactive():
18 17 global _pipe, _session, _checked
19 18 if _pipe is None:
20 19 if _checked:
21 yield
22 return
20 return False
23 21 _checked = True
24 22 if 'HGCATAPULTSERVERPIPE' not in os.environ:
25 yield
26 return
23 return False
27 24 _pipe = open(os.environ['HGCATAPULTSERVERPIPE'], 'w', 1)
28 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 33 whence = whencefmt % whenceargs
30 34 try:
31 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