Mercurial > public > mercurial-scm > hg-stable
annotate mercurial/loggingutil.py @ 49263:63fd0282ad40
node: stop converting binascii.Error to TypeError in bin()
Changeset f574cc00831a introduced the wrapper, to make bin() behave like on
Python 2, where it raised TypeError in many cases. Another previous approach,
changing callers to catch binascii.Error in addition to TypeError, was backed
out after negative review feedback [1].
However, I think it?s worth reconsidering the approach. Now that we?re on
Python 3 only, callers have to catch only binascii.Error instead of both.
Catching binascii.Error instead of TypeError has the advantage that it?s less
likely to cover a programming error (e.g. passing an int to bin() raises
TypeError). Also, raising TypeError never made sense semantically when bin()
got an argument of valid type.
As a side-effect, this fixed an exception in test-http-bad-server.t. The TODO
was outdated: it was not an uncaught ValueError in batch.results() but uncaught
TypeError from the now removed wrapper. Now that bin() raises binascii.Error
instead of TypeError, it gets converted to a proper error in
wirepeer.heads.<locals>.decode() that catches ValueError (superclass of
binascii.Error). This is a good example of why this changeset is a good idea.
Catching TypeError instead of ValueError there would not make much sense.
[1] https://phab.mercurial-scm.org/D2244
author | Manuel Jacob <me@manueljacob.de> |
---|---|
date | Mon, 30 May 2022 16:18:12 +0200 |
parents | 642e31cb55f0 |
children | d44e3c45f0e4 |
rev | line source |
---|---|
40828
03127e580980
loggingutil: extract openlogfile() and proxylogger to new module
Yuya Nishihara <yuya@tcha.org>
parents:
40827
diff
changeset
|
1 # loggingutil.py - utility for logging events |
18669
18242716a014
blackbox: adds a blackbox extension
Durham Goode <durham@fb.com>
parents:
diff
changeset
|
2 # |
18676 | 3 # Copyright 2010 Nicolas Dumazet |
18669
18242716a014
blackbox: adds a blackbox extension
Durham Goode <durham@fb.com>
parents:
diff
changeset
|
4 # Copyright 2013 Facebook, Inc. |
18242716a014
blackbox: adds a blackbox extension
Durham Goode <durham@fb.com>
parents:
diff
changeset
|
5 # |
18242716a014
blackbox: adds a blackbox extension
Durham Goode <durham@fb.com>
parents:
diff
changeset
|
6 # This software may be used and distributed according to the terms of the |
18242716a014
blackbox: adds a blackbox extension
Durham Goode <durham@fb.com>
parents:
diff
changeset
|
7 # GNU General Public License version 2 or any later version. |
18242716a014
blackbox: adds a blackbox extension
Durham Goode <durham@fb.com>
parents:
diff
changeset
|
8 |
28090
8113c88b8e6d
blackbox: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28027
diff
changeset
|
9 |
8113c88b8e6d
blackbox: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28027
diff
changeset
|
10 import errno |
8113c88b8e6d
blackbox: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28027
diff
changeset
|
11 |
46892
4a6024b87dfc
blackbox: fix type error on log rotation on read-only filesystem
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents:
43077
diff
changeset
|
12 from . import ( |
4a6024b87dfc
blackbox: fix type error on log rotation on read-only filesystem
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents:
43077
diff
changeset
|
13 encoding, |
4a6024b87dfc
blackbox: fix type error on log rotation on read-only filesystem
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents:
43077
diff
changeset
|
14 pycompat, |
4a6024b87dfc
blackbox: fix type error on log rotation on read-only filesystem
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents:
43077
diff
changeset
|
15 ) |
18669
18242716a014
blackbox: adds a blackbox extension
Durham Goode <durham@fb.com>
parents:
diff
changeset
|
16 |
40839
96be0ecad648
loggingutil: add basic logger backends
Yuya Nishihara <yuya@tcha.org>
parents:
40829
diff
changeset
|
17 from .utils import ( |
96be0ecad648
loggingutil: add basic logger backends
Yuya Nishihara <yuya@tcha.org>
parents:
40829
diff
changeset
|
18 dateutil, |
96be0ecad648
loggingutil: add basic logger backends
Yuya Nishihara <yuya@tcha.org>
parents:
40829
diff
changeset
|
19 procutil, |
96be0ecad648
loggingutil: add basic logger backends
Yuya Nishihara <yuya@tcha.org>
parents:
40829
diff
changeset
|
20 stringutil, |
96be0ecad648
loggingutil: add basic logger backends
Yuya Nishihara <yuya@tcha.org>
parents:
40829
diff
changeset
|
21 ) |
96be0ecad648
loggingutil: add basic logger backends
Yuya Nishihara <yuya@tcha.org>
parents:
40829
diff
changeset
|
22 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40839
diff
changeset
|
23 |
40828
03127e580980
loggingutil: extract openlogfile() and proxylogger to new module
Yuya Nishihara <yuya@tcha.org>
parents:
40827
diff
changeset
|
24 def openlogfile(ui, vfs, name, maxfiles=0, maxsize=0): |
40829
698477777883
loggingutil: document openlogfile()
Yuya Nishihara <yuya@tcha.org>
parents:
40828
diff
changeset
|
25 """Open log file in append mode, with optional rotation |
698477777883
loggingutil: document openlogfile()
Yuya Nishihara <yuya@tcha.org>
parents:
40828
diff
changeset
|
26 |
698477777883
loggingutil: document openlogfile()
Yuya Nishihara <yuya@tcha.org>
parents:
40828
diff
changeset
|
27 If maxsize > 0, the log file will be rotated up to maxfiles. |
698477777883
loggingutil: document openlogfile()
Yuya Nishihara <yuya@tcha.org>
parents:
40828
diff
changeset
|
28 """ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40839
diff
changeset
|
29 |
34307
e6723c939344
blackbox: move _openlogfile to a separate method
Jun Wu <quark@fb.com>
parents:
34306
diff
changeset
|
30 def rotate(oldpath, newpath): |
e6723c939344
blackbox: move _openlogfile to a separate method
Jun Wu <quark@fb.com>
parents:
34306
diff
changeset
|
31 try: |
e6723c939344
blackbox: move _openlogfile to a separate method
Jun Wu <quark@fb.com>
parents:
34306
diff
changeset
|
32 vfs.unlink(newpath) |
e6723c939344
blackbox: move _openlogfile to a separate method
Jun Wu <quark@fb.com>
parents:
34306
diff
changeset
|
33 except OSError as err: |
e6723c939344
blackbox: move _openlogfile to a separate method
Jun Wu <quark@fb.com>
parents:
34306
diff
changeset
|
34 if err.errno != errno.ENOENT: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40839
diff
changeset
|
35 ui.debug( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
36 b"warning: cannot remove '%s': %s\n" |
46892
4a6024b87dfc
blackbox: fix type error on log rotation on read-only filesystem
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents:
43077
diff
changeset
|
37 % (newpath, encoding.strtolocal(err.strerror)) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40839
diff
changeset
|
38 ) |
34307
e6723c939344
blackbox: move _openlogfile to a separate method
Jun Wu <quark@fb.com>
parents:
34306
diff
changeset
|
39 try: |
e6723c939344
blackbox: move _openlogfile to a separate method
Jun Wu <quark@fb.com>
parents:
34306
diff
changeset
|
40 if newpath: |
e6723c939344
blackbox: move _openlogfile to a separate method
Jun Wu <quark@fb.com>
parents:
34306
diff
changeset
|
41 vfs.rename(oldpath, newpath) |
e6723c939344
blackbox: move _openlogfile to a separate method
Jun Wu <quark@fb.com>
parents:
34306
diff
changeset
|
42 except OSError as err: |
e6723c939344
blackbox: move _openlogfile to a separate method
Jun Wu <quark@fb.com>
parents:
34306
diff
changeset
|
43 if err.errno != errno.ENOENT: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40839
diff
changeset
|
44 ui.debug( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
45 b"warning: cannot rename '%s' to '%s': %s\n" |
46892
4a6024b87dfc
blackbox: fix type error on log rotation on read-only filesystem
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents:
43077
diff
changeset
|
46 % (newpath, oldpath, encoding.strtolocal(err.strerror)) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40839
diff
changeset
|
47 ) |
34307
e6723c939344
blackbox: move _openlogfile to a separate method
Jun Wu <quark@fb.com>
parents:
34306
diff
changeset
|
48 |
e6723c939344
blackbox: move _openlogfile to a separate method
Jun Wu <quark@fb.com>
parents:
34306
diff
changeset
|
49 if maxsize > 0: |
e6723c939344
blackbox: move _openlogfile to a separate method
Jun Wu <quark@fb.com>
parents:
34306
diff
changeset
|
50 try: |
e6723c939344
blackbox: move _openlogfile to a separate method
Jun Wu <quark@fb.com>
parents:
34306
diff
changeset
|
51 st = vfs.stat(name) |
e6723c939344
blackbox: move _openlogfile to a separate method
Jun Wu <quark@fb.com>
parents:
34306
diff
changeset
|
52 except OSError: |
e6723c939344
blackbox: move _openlogfile to a separate method
Jun Wu <quark@fb.com>
parents:
34306
diff
changeset
|
53 pass |
e6723c939344
blackbox: move _openlogfile to a separate method
Jun Wu <quark@fb.com>
parents:
34306
diff
changeset
|
54 else: |
e6723c939344
blackbox: move _openlogfile to a separate method
Jun Wu <quark@fb.com>
parents:
34306
diff
changeset
|
55 if st.st_size >= maxsize: |
e6723c939344
blackbox: move _openlogfile to a separate method
Jun Wu <quark@fb.com>
parents:
34306
diff
changeset
|
56 path = vfs.join(name) |
38823
e7aa113b14f7
global: use pycompat.xrange()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37123
diff
changeset
|
57 for i in pycompat.xrange(maxfiles - 1, 1, -1): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40839
diff
changeset
|
58 rotate( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
59 oldpath=b'%s.%d' % (path, i - 1), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
60 newpath=b'%s.%d' % (path, i), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40839
diff
changeset
|
61 ) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
62 rotate(oldpath=path, newpath=maxfiles > 0 and path + b'.1') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
63 return vfs(name, b'a', makeparentdirs=False) |
34307
e6723c939344
blackbox: move _openlogfile to a separate method
Jun Wu <quark@fb.com>
parents:
34306
diff
changeset
|
64 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40839
diff
changeset
|
65 |
40839
96be0ecad648
loggingutil: add basic logger backends
Yuya Nishihara <yuya@tcha.org>
parents:
40829
diff
changeset
|
66 def _formatlogline(msg): |
96be0ecad648
loggingutil: add basic logger backends
Yuya Nishihara <yuya@tcha.org>
parents:
40829
diff
changeset
|
67 date = dateutil.datestr(format=b'%Y/%m/%d %H:%M:%S') |
96be0ecad648
loggingutil: add basic logger backends
Yuya Nishihara <yuya@tcha.org>
parents:
40829
diff
changeset
|
68 pid = procutil.getpid() |
96be0ecad648
loggingutil: add basic logger backends
Yuya Nishihara <yuya@tcha.org>
parents:
40829
diff
changeset
|
69 return b'%s (%d)> %s' % (date, pid, msg) |
96be0ecad648
loggingutil: add basic logger backends
Yuya Nishihara <yuya@tcha.org>
parents:
40829
diff
changeset
|
70 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40839
diff
changeset
|
71 |
40839
96be0ecad648
loggingutil: add basic logger backends
Yuya Nishihara <yuya@tcha.org>
parents:
40829
diff
changeset
|
72 def _matchevent(event, tracked): |
96be0ecad648
loggingutil: add basic logger backends
Yuya Nishihara <yuya@tcha.org>
parents:
40829
diff
changeset
|
73 return b'*' in tracked or event in tracked |
96be0ecad648
loggingutil: add basic logger backends
Yuya Nishihara <yuya@tcha.org>
parents:
40829
diff
changeset
|
74 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40839
diff
changeset
|
75 |
49037
642e31cb55f0
py3: use class X: instead of class X(object):
Gregory Szorc <gregory.szorc@gmail.com>
parents:
48966
diff
changeset
|
76 class filelogger: |
40839
96be0ecad648
loggingutil: add basic logger backends
Yuya Nishihara <yuya@tcha.org>
parents:
40829
diff
changeset
|
77 """Basic logger backed by physical file with optional rotation""" |
96be0ecad648
loggingutil: add basic logger backends
Yuya Nishihara <yuya@tcha.org>
parents:
40829
diff
changeset
|
78 |
96be0ecad648
loggingutil: add basic logger backends
Yuya Nishihara <yuya@tcha.org>
parents:
40829
diff
changeset
|
79 def __init__(self, vfs, name, tracked, maxfiles=0, maxsize=0): |
96be0ecad648
loggingutil: add basic logger backends
Yuya Nishihara <yuya@tcha.org>
parents:
40829
diff
changeset
|
80 self._vfs = vfs |
96be0ecad648
loggingutil: add basic logger backends
Yuya Nishihara <yuya@tcha.org>
parents:
40829
diff
changeset
|
81 self._name = name |
96be0ecad648
loggingutil: add basic logger backends
Yuya Nishihara <yuya@tcha.org>
parents:
40829
diff
changeset
|
82 self._trackedevents = set(tracked) |
96be0ecad648
loggingutil: add basic logger backends
Yuya Nishihara <yuya@tcha.org>
parents:
40829
diff
changeset
|
83 self._maxfiles = maxfiles |
96be0ecad648
loggingutil: add basic logger backends
Yuya Nishihara <yuya@tcha.org>
parents:
40829
diff
changeset
|
84 self._maxsize = maxsize |
96be0ecad648
loggingutil: add basic logger backends
Yuya Nishihara <yuya@tcha.org>
parents:
40829
diff
changeset
|
85 |
96be0ecad648
loggingutil: add basic logger backends
Yuya Nishihara <yuya@tcha.org>
parents:
40829
diff
changeset
|
86 def tracked(self, event): |
96be0ecad648
loggingutil: add basic logger backends
Yuya Nishihara <yuya@tcha.org>
parents:
40829
diff
changeset
|
87 return _matchevent(event, self._trackedevents) |
96be0ecad648
loggingutil: add basic logger backends
Yuya Nishihara <yuya@tcha.org>
parents:
40829
diff
changeset
|
88 |
96be0ecad648
loggingutil: add basic logger backends
Yuya Nishihara <yuya@tcha.org>
parents:
40829
diff
changeset
|
89 def log(self, ui, event, msg, opts): |
96be0ecad648
loggingutil: add basic logger backends
Yuya Nishihara <yuya@tcha.org>
parents:
40829
diff
changeset
|
90 line = _formatlogline(msg) |
96be0ecad648
loggingutil: add basic logger backends
Yuya Nishihara <yuya@tcha.org>
parents:
40829
diff
changeset
|
91 try: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40839
diff
changeset
|
92 with openlogfile( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40839
diff
changeset
|
93 ui, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40839
diff
changeset
|
94 self._vfs, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40839
diff
changeset
|
95 self._name, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40839
diff
changeset
|
96 maxfiles=self._maxfiles, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40839
diff
changeset
|
97 maxsize=self._maxsize, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40839
diff
changeset
|
98 ) as fp: |
40839
96be0ecad648
loggingutil: add basic logger backends
Yuya Nishihara <yuya@tcha.org>
parents:
40829
diff
changeset
|
99 fp.write(line) |
96be0ecad648
loggingutil: add basic logger backends
Yuya Nishihara <yuya@tcha.org>
parents:
40829
diff
changeset
|
100 except IOError as err: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40839
diff
changeset
|
101 ui.debug( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40839
diff
changeset
|
102 b'cannot write to %s: %s\n' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40839
diff
changeset
|
103 % (self._name, stringutil.forcebytestr(err)) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40839
diff
changeset
|
104 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40839
diff
changeset
|
105 |
40839
96be0ecad648
loggingutil: add basic logger backends
Yuya Nishihara <yuya@tcha.org>
parents:
40829
diff
changeset
|
106 |
49037
642e31cb55f0
py3: use class X: instead of class X(object):
Gregory Szorc <gregory.szorc@gmail.com>
parents:
48966
diff
changeset
|
107 class fileobjectlogger: |
40839
96be0ecad648
loggingutil: add basic logger backends
Yuya Nishihara <yuya@tcha.org>
parents:
40829
diff
changeset
|
108 """Basic logger backed by file-like object""" |
96be0ecad648
loggingutil: add basic logger backends
Yuya Nishihara <yuya@tcha.org>
parents:
40829
diff
changeset
|
109 |
96be0ecad648
loggingutil: add basic logger backends
Yuya Nishihara <yuya@tcha.org>
parents:
40829
diff
changeset
|
110 def __init__(self, fp, tracked): |
96be0ecad648
loggingutil: add basic logger backends
Yuya Nishihara <yuya@tcha.org>
parents:
40829
diff
changeset
|
111 self._fp = fp |
96be0ecad648
loggingutil: add basic logger backends
Yuya Nishihara <yuya@tcha.org>
parents:
40829
diff
changeset
|
112 self._trackedevents = set(tracked) |
96be0ecad648
loggingutil: add basic logger backends
Yuya Nishihara <yuya@tcha.org>
parents:
40829
diff
changeset
|
113 |
96be0ecad648
loggingutil: add basic logger backends
Yuya Nishihara <yuya@tcha.org>
parents:
40829
diff
changeset
|
114 def tracked(self, event): |
96be0ecad648
loggingutil: add basic logger backends
Yuya Nishihara <yuya@tcha.org>
parents:
40829
diff
changeset
|
115 return _matchevent(event, self._trackedevents) |
96be0ecad648
loggingutil: add basic logger backends
Yuya Nishihara <yuya@tcha.org>
parents:
40829
diff
changeset
|
116 |
96be0ecad648
loggingutil: add basic logger backends
Yuya Nishihara <yuya@tcha.org>
parents:
40829
diff
changeset
|
117 def log(self, ui, event, msg, opts): |
96be0ecad648
loggingutil: add basic logger backends
Yuya Nishihara <yuya@tcha.org>
parents:
40829
diff
changeset
|
118 line = _formatlogline(msg) |
96be0ecad648
loggingutil: add basic logger backends
Yuya Nishihara <yuya@tcha.org>
parents:
40829
diff
changeset
|
119 try: |
96be0ecad648
loggingutil: add basic logger backends
Yuya Nishihara <yuya@tcha.org>
parents:
40829
diff
changeset
|
120 self._fp.write(line) |
96be0ecad648
loggingutil: add basic logger backends
Yuya Nishihara <yuya@tcha.org>
parents:
40829
diff
changeset
|
121 self._fp.flush() |
96be0ecad648
loggingutil: add basic logger backends
Yuya Nishihara <yuya@tcha.org>
parents:
40829
diff
changeset
|
122 except IOError as err: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40839
diff
changeset
|
123 ui.debug( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40839
diff
changeset
|
124 b'cannot write to %s: %s\n' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40839
diff
changeset
|
125 % ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40839
diff
changeset
|
126 stringutil.forcebytestr(self._fp.name), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40839
diff
changeset
|
127 stringutil.forcebytestr(err), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40839
diff
changeset
|
128 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40839
diff
changeset
|
129 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40839
diff
changeset
|
130 |
40839
96be0ecad648
loggingutil: add basic logger backends
Yuya Nishihara <yuya@tcha.org>
parents:
40829
diff
changeset
|
131 |
49037
642e31cb55f0
py3: use class X: instead of class X(object):
Gregory Szorc <gregory.szorc@gmail.com>
parents:
48966
diff
changeset
|
132 class proxylogger: |
40796
37d6ee46a965
blackbox: extract global last logger to proxylogger class
Yuya Nishihara <yuya@tcha.org>
parents:
40794
diff
changeset
|
133 """Forward log events to another logger to be set later""" |
37d6ee46a965
blackbox: extract global last logger to proxylogger class
Yuya Nishihara <yuya@tcha.org>
parents:
40794
diff
changeset
|
134 |
37d6ee46a965
blackbox: extract global last logger to proxylogger class
Yuya Nishihara <yuya@tcha.org>
parents:
40794
diff
changeset
|
135 def __init__(self): |
37d6ee46a965
blackbox: extract global last logger to proxylogger class
Yuya Nishihara <yuya@tcha.org>
parents:
40794
diff
changeset
|
136 self.logger = None |
37d6ee46a965
blackbox: extract global last logger to proxylogger class
Yuya Nishihara <yuya@tcha.org>
parents:
40794
diff
changeset
|
137 |
37d6ee46a965
blackbox: extract global last logger to proxylogger class
Yuya Nishihara <yuya@tcha.org>
parents:
40794
diff
changeset
|
138 def tracked(self, event): |
37d6ee46a965
blackbox: extract global last logger to proxylogger class
Yuya Nishihara <yuya@tcha.org>
parents:
40794
diff
changeset
|
139 return self.logger is not None and self.logger.tracked(event) |
37d6ee46a965
blackbox: extract global last logger to proxylogger class
Yuya Nishihara <yuya@tcha.org>
parents:
40794
diff
changeset
|
140 |
37d6ee46a965
blackbox: extract global last logger to proxylogger class
Yuya Nishihara <yuya@tcha.org>
parents:
40794
diff
changeset
|
141 def log(self, ui, event, msg, opts): |
37d6ee46a965
blackbox: extract global last logger to proxylogger class
Yuya Nishihara <yuya@tcha.org>
parents:
40794
diff
changeset
|
142 assert self.logger is not None |
37d6ee46a965
blackbox: extract global last logger to proxylogger class
Yuya Nishihara <yuya@tcha.org>
parents:
40794
diff
changeset
|
143 self.logger.log(ui, event, msg, opts) |