MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / LogRedactor

Class LogRedactor

tools/tasks.py:35–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33
34
35class LogRedactor:
36 def __init__(self, salt: str, tmpdir: Union[str, pathlib.Path]):
37 self.target_dir = os.path.join(tmpdir, "redacted")
38 os.makedirs(self.target_dir)
39
40 self.couchbase_log = CouchbaseLogProcessor(salt)
41 self.regular_log = RegularLogProcessor(salt)
42
43 def _process_file(self, ifile, ofile, processor):
44 try:
45 with get_open_fn(ifile)(
46 ifile,
47 "rb",
48 ) as inp:
49 with get_open_fn(ofile)(
50 ofile,
51 "wb+",
52 ) as out:
53 # Write redaction header
54 out.write(self.couchbase_log.do(b"RedactLevel"))
55 for line in inp:
56 out.write(processor.do(line))
57 except IOError as e:
58 log("I/O error(%s): %s" % (e.errno, e.strerror))
59
60 def redact_file(self, name, ifile):
61 _, filename = os.path.split(name)
62 ofile = os.path.join(self.target_dir, filename)
63 self._process_file(ifile, ofile, self.regular_log)
64 return ofile
65
66
67class CouchbaseLogProcessor:

Callers 1

redact_and_zipMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected