Show More
@@ -127,8 +127,11 b' def _openlogfile(ui, vfs):' | |||
|
127 | 127 | newpath=maxfiles > 0 and path + '.1') |
|
128 | 128 | return vfs(name, 'a') |
|
129 | 129 | |
|
130 | def wrapui(ui): | |
|
131 |
class blackbox |
|
|
130 | if True: | |
|
131 | class blackboxlogger(object): | |
|
132 | def __init__(self, ui): | |
|
133 | self.track = ui.configlist('blackbox', 'track') | |
|
134 | ||
|
132 | 135 | @property |
|
133 | 136 | def _bbvfs(self): |
|
134 | 137 | vfs = None |
@@ -139,19 +142,8 b' def wrapui(ui):' | |||
|
139 | 142 | vfs = None |
|
140 | 143 | return vfs |
|
141 | 144 | |
|
142 | @util.propertycache | |
|
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): | |
|
145 | def log(self, ui, event, msg, opts): | |
|
152 | 146 | global _lastlogger |
|
153 | super(blackboxui, self).log(event, *msg, **opts) | |
|
154 | ||
|
155 | 147 | if not '*' in self.track and not event in self.track: |
|
156 | 148 | return |
|
157 | 149 | |
@@ -164,7 +156,7 b' def wrapui(ui):' | |||
|
164 | 156 | pass |
|
165 | 157 | else: |
|
166 | 158 | return |
|
167 |
_lastlogger._log( |
|
|
159 | _lastlogger._log(ui, event, msg, opts) | |
|
168 | 160 | |
|
169 | 161 | def _log(self, ui, event, msg, opts): |
|
170 | 162 | if getattr(self, '_bbinlog', False): |
@@ -205,6 +197,29 b' def wrapui(ui):' | |||
|
205 | 197 | def setrepo(self, repo): |
|
206 | 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 | 223 | ui.__class__ = blackboxui |
|
209 | 224 | uimod.ui = blackboxui |
|
210 | 225 | |
@@ -218,8 +233,8 b' def reposetup(ui, repo):' | |||
|
218 | 233 | if not repo.local(): |
|
219 | 234 | return |
|
220 | 235 | |
|
221 | if util.safehasattr(ui, 'setrepo'): | |
|
222 |
|
|
|
236 | logger = getattr(ui, '_bblogger', None) | |
|
237 | if logger: | |
|
223 | 238 | logger.setrepo(repo) |
|
224 | 239 | |
|
225 | 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