-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscrubber.h
34 lines (25 loc) · 1.23 KB
/
scrubber.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
32
33
34
// Copyright 2017 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef VM_TOOLS_SYSLOG_SCRUBBER_H_
#define VM_TOOLS_SYSLOG_SCRUBBER_H_
#include <string>
#include <vm_protos/proto_bindings/vm_host.grpc.pb.h>
namespace vm_tools {
namespace syslog {
// Parses |severity| and returns a string that can be used as a valid PRI part
// of a syslog message.
std::string ParseProtoSeverity(vm_tools::LogSeverity severity);
// Parses |timestamp| into an RFC3164 compliant string that can be included as
// part of a syslog message.
std::string ParseProtoTimestamp(const vm_tools::Timestamp& timestamp);
// Scrubs |content| and returns a valid UTF-8 string. Assumes |content| is
// encoded as UTF-8. Invalid code points are replaced with (U+fffd). Control
// characters and other valid but non-character code points are converted into
// octal numbers with a minimum width of 3 digits and prefixed with '#'. For
// example if the BEL character (U+0007) appears in |content| it will be
// converted to "#007".
std::string ScrubProtoContent(const std::string& content);
} // namespace syslog
} // namespace vm_tools
#endif // VM_TOOLS_SYSLOG_SCRUBBER_H_