blob: ea7da16a52751c11a5f2eea555410e8f2e4499f9 [file] [log] [blame]
android-t13d2c5b22022-10-12 13:43:18 +08001// Copyright (c) 2022 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4#ifndef THIRD_PARTY_ZLIB_GOOGLE_REDACT_H_
5#define THIRD_PARTY_ZLIB_GOOGLE_REDACT_H_
6
7#include <ostream>
8
9#include "base/files/file_path.h"
10#include "base/logging.h"
11
12namespace zip {
13
14// Redacts file paths in log messages.
15// Example:
16// LOG(ERROR) << "Cannot open " << Redact(path);
17class Redact {
18 public:
19 explicit Redact(const base::FilePath& path) : path_(path) {}
20
21 friend std::ostream& operator<<(std::ostream& out, const Redact&& r) {
22 return LOG_IS_ON(INFO) ? out << "'" << r.path_ << "'" : out << "(redacted)";
23 }
24
25 private:
26 const base::FilePath& path_;
27};
28
29} // namespace zip
30
31#endif // THIRD_PARTY_ZLIB_GOOGLE_REDACT_H_