Show More
@@ -127,8 +127,11 b' def _openlogfile(ui, vfs):' | |||||
127 | newpath=maxfiles > 0 and path + '.1') |
|
127 | newpath=maxfiles > 0 and path + '.1') | |
128 | return vfs(name, 'a') |
|
128 | return vfs(name, 'a') | |
129 |
|
129 | |||
130 | def wrapui(ui): |
|
130 | if True: | |
131 |
class blackbox |
|
131 | class blackboxlogger(object): | |
|
132 | def __init__(self, ui): | |||
|
133 | self.track = ui.configlist('blackbox', 'track') | |||
|
134 | ||||
132 | @property |
|
135 | @property | |
133 | def _bbvfs(self): |
|
136 | def _bbvfs(self): | |
134 | vfs = None |
|
137 | vfs = None | |
@@ -139,19 +142,8 b' def wrapui(ui):' | |||||
139 | vfs = None |
|
142 | vfs = None | |
140 | return vfs |
|
143 | return vfs | |
141 |
|
144 | |||
142 | @util.propertycache |
|
145 | def log(self, ui, event, msg, opts): | |
143 | def track(self): |
|
|||
144 | return self.configlist('blackbox', 'track') |
|
|||
145 |
|
||||
146 | def debug(self, *msg, **opts): |
|
|||
147 | super(blackboxui, self).debug(*msg, **opts) |
|
|||
148 | if self.debugflag: |
|
|||
149 | self.log('debug', '%s', ''.join(msg)) |
|
|||
150 |
|
||||
151 | def log(self, event, *msg, **opts): |
|
|||
152 | global _lastlogger |
|
146 | global _lastlogger | |
153 | super(blackboxui, self).log(event, *msg, **opts) |
|
|||
154 |
|
||||
155 | if not '*' in self.track and not event in self.track: |
|
147 | if not '*' in self.track and not event in self.track: | |
156 | return |
|
148 | return | |
157 |
|
149 | |||
@@ -164,7 +156,7 b' def wrapui(ui):' | |||||
164 | pass |
|
156 | pass | |
165 | else: |
|
157 | else: | |
166 | return |
|
158 | return | |
167 |
_lastlogger._log( |
|
159 | _lastlogger._log(ui, event, msg, opts) | |
168 |
|
160 | |||
169 | def _log(self, ui, event, msg, opts): |
|
161 | def _log(self, ui, event, msg, opts): | |
170 | if getattr(self, '_bbinlog', False): |
|
162 | if getattr(self, '_bbinlog', False): | |
@@ -205,6 +197,29 b' def wrapui(ui):' | |||||
205 | def setrepo(self, repo): |
|
197 | def setrepo(self, repo): | |
206 | self._bbrepo = repo |
|
198 | self._bbrepo = repo | |
207 |
|
199 | |||
|
200 | def wrapui(ui): | |||
|
201 | class blackboxui(ui.__class__): | |||
|
202 | def __init__(self, src=None): | |||
|
203 | super(blackboxui, self).__init__(src) | |||
|
204 | if src and r'_bblogger' in src.__dict__: | |||
|
205 | self._bblogger = src._bblogger | |||
|
206 | ||||
|
207 | # trick to initialize logger after configuration is loaded, which | |||
|
208 | # can be replaced later with blackboxlogger(ui) in uisetup(), where | |||
|
209 | # both user and repo configurations should be available. | |||
|
210 | @util.propertycache | |||
|
211 | def _bblogger(self): | |||
|
212 | return blackboxlogger(self) | |||
|
213 | ||||
|
214 | def debug(self, *msg, **opts): | |||
|
215 | super(blackboxui, self).debug(*msg, **opts) | |||
|
216 | if self.debugflag: | |||
|
217 | self.log('debug', '%s', ''.join(msg)) | |||
|
218 | ||||
|
219 | def log(self, event, *msg, **opts): | |||
|
220 | super(blackboxui, self).log(event, *msg, **opts) | |||
|
221 | self._bblogger.log(self, event, msg, opts) | |||
|
222 | ||||
208 | ui.__class__ = blackboxui |
|
223 | ui.__class__ = blackboxui | |
209 | uimod.ui = blackboxui |
|
224 | uimod.ui = blackboxui | |
210 |
|
225 | |||
@@ -218,8 +233,8 b' def reposetup(ui, repo):' | |||||
218 | if not repo.local(): |
|
233 | if not repo.local(): | |
219 | return |
|
234 | return | |
220 |
|
235 | |||
221 | if util.safehasattr(ui, 'setrepo'): |
|
236 | logger = getattr(ui, '_bblogger', None) | |
222 |
|
|
237 | if logger: | |
223 | logger.setrepo(repo) |
|
238 | logger.setrepo(repo) | |
224 |
|
239 | |||
225 | # Set _lastlogger even if ui.log is not called. This gives blackbox a |
|
240 | # Set _lastlogger even if ui.log is not called. This gives blackbox a |
General Comments 0
You need to be logged in to leave comments.
Login now