forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathredact.h
31 lines (23 loc) · 784 Bytes
/
redact.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef THIRD_PARTY_ZLIB_GOOGLE_REDACT_H_
#define THIRD_PARTY_ZLIB_GOOGLE_REDACT_H_
#include <ostream>
#include "base/files/file_path.h"
#include "base/logging.h"
namespace zip {
// Redacts file paths in log messages.
// Example:
// LOG(ERROR) << "Cannot open " << Redact(path);
class Redact {
public:
explicit Redact(const base::FilePath& path) : path_(path) {}
friend std::ostream& operator<<(std::ostream& out, const Redact&& r) {
return LOG_IS_ON(INFO) ? out << "'" << r.path_ << "'" : out << "(redacted)";
}
private:
const base::FilePath& path_;
};
} // namespace zip
#endif // THIRD_PARTY_ZLIB_GOOGLE_REDACT_H_