Show More
@@ -127,75 +127,73 b' def _openlogfile(ui, vfs):' | |||
|
127 | 127 | newpath=maxfiles > 0 and path + '.1') |
|
128 | 128 | return vfs(name, 'a') |
|
129 | 129 | |
|
130 | if True: | |
|
131 | class blackboxlogger(object): | |
|
132 | def __init__(self, ui): | |
|
133 | self.track = ui.configlist('blackbox', 'track') | |
|
130 | class blackboxlogger(object): | |
|
131 | def __init__(self, ui): | |
|
132 | self.track = ui.configlist('blackbox', 'track') | |
|
134 | 133 | |
|
135 |
|
|
|
136 |
|
|
|
137 |
|
|
|
138 |
|
|
|
139 |
|
|
|
140 |
|
|
|
141 |
|
|
|
142 |
|
|
|
143 |
|
|
|
134 | @property | |
|
135 | def _bbvfs(self): | |
|
136 | vfs = None | |
|
137 | repo = getattr(self, '_bbrepo', None) | |
|
138 | if repo: | |
|
139 | vfs = repo.vfs | |
|
140 | if not vfs.isdir('.'): | |
|
141 | vfs = None | |
|
142 | return vfs | |
|
144 | 143 | |
|
145 |
|
|
|
146 |
|
|
|
147 |
|
|
|
148 |
|
|
|
144 | def log(self, ui, event, msg, opts): | |
|
145 | global _lastlogger | |
|
146 | if not '*' in self.track and not event in self.track: | |
|
147 | return | |
|
149 | 148 | |
|
150 |
|
|
|
151 |
|
|
|
152 |
|
|
|
153 |
|
|
|
154 |
|
|
|
155 |
|
|
|
156 |
|
|
|
157 |
|
|
|
158 |
|
|
|
159 |
|
|
|
149 | if self._bbvfs: | |
|
150 | _lastlogger = self | |
|
151 | elif _lastlogger and _lastlogger._bbvfs: | |
|
152 | # certain logger instances exist outside the context of | |
|
153 | # a repo, so just default to the last blackbox logger that | |
|
154 | # was seen. | |
|
155 | pass | |
|
156 | else: | |
|
157 | return | |
|
158 | _lastlogger._log(ui, event, msg, opts) | |
|
160 | 159 | |
|
161 |
|
|
|
162 |
|
|
|
163 |
|
|
|
164 |
|
|
|
165 |
|
|
|
166 |
|
|
|
167 |
|
|
|
168 | ui.config('blackbox', 'date-format')) | |
|
169 |
|
|
|
170 | pid = '%d' % procutil.getpid() | |
|
171 | formattedmsg = msg[0] % msg[1:] | |
|
172 | rev = '(unknown)' | |
|
173 | changed = '' | |
|
174 | ctx = self._bbrepo[None] | |
|
175 | parents = ctx.parents() | |
|
176 | rev = ('+'.join([hex(p.node()) for p in parents])) | |
|
177 | if (ui.configbool('blackbox', 'dirty') and | |
|
178 | ctx.dirty(missing=True, merge=False, branch=False)): | |
|
179 | changed = '+' | |
|
180 | if ui.configbool('blackbox', 'logsource'): | |
|
181 | src = ' [%s]' % event | |
|
182 |
|
|
|
183 | src = '' | |
|
184 | try: | |
|
185 | fmt = '%s %s @%s%s (%s)%s> %s' | |
|
186 | args = (date, user, rev, changed, pid, src, formattedmsg) | |
|
187 | with _openlogfile(ui, self._bbvfs) as fp: | |
|
188 | fp.write(fmt % args) | |
|
189 | except (IOError, OSError) as err: | |
|
190 | ui.debug('warning: cannot write to blackbox.log: %s\n' % | |
|
191 | encoding.strtolocal(err.strerror)) | |
|
192 | # do not restore _bbinlog intentionally to avoid failed | |
|
193 | # logging again | |
|
194 |
else |
|
|
195 | self._bbinlog = False | |
|
160 | def _log(self, ui, event, msg, opts): | |
|
161 | if getattr(self, '_bbinlog', False): | |
|
162 | # recursion and failure guard | |
|
163 | return | |
|
164 | self._bbinlog = True | |
|
165 | default = ui.configdate('devel', 'default-date') | |
|
166 | date = dateutil.datestr(default, ui.config('blackbox', 'date-format')) | |
|
167 | user = procutil.getuser() | |
|
168 | pid = '%d' % procutil.getpid() | |
|
169 | formattedmsg = msg[0] % msg[1:] | |
|
170 | rev = '(unknown)' | |
|
171 | changed = '' | |
|
172 | ctx = self._bbrepo[None] | |
|
173 | parents = ctx.parents() | |
|
174 | rev = ('+'.join([hex(p.node()) for p in parents])) | |
|
175 | if (ui.configbool('blackbox', 'dirty') and | |
|
176 | ctx.dirty(missing=True, merge=False, branch=False)): | |
|
177 | changed = '+' | |
|
178 | if ui.configbool('blackbox', 'logsource'): | |
|
179 | src = ' [%s]' % event | |
|
180 | else: | |
|
181 | src = '' | |
|
182 | try: | |
|
183 | fmt = '%s %s @%s%s (%s)%s> %s' | |
|
184 | args = (date, user, rev, changed, pid, src, formattedmsg) | |
|
185 | with _openlogfile(ui, self._bbvfs) as fp: | |
|
186 | fp.write(fmt % args) | |
|
187 | except (IOError, OSError) as err: | |
|
188 | ui.debug('warning: cannot write to blackbox.log: %s\n' % | |
|
189 | encoding.strtolocal(err.strerror)) | |
|
190 | # do not restore _bbinlog intentionally to avoid failed | |
|
191 | # logging again | |
|
192 | else: | |
|
193 | self._bbinlog = False | |
|
196 | 194 | |
|
197 |
|
|
|
198 |
|
|
|
195 | def setrepo(self, repo): | |
|
196 | self._bbrepo = repo | |
|
199 | 197 | |
|
200 | 198 | def wrapui(ui): |
|
201 | 199 | class blackboxui(ui.__class__): |
General Comments 0
You need to be logged in to leave comments.
Login now