blob: 07e68a82112d237aeda51f77d9bebc83a9b38976 [file] [log] [blame]
Steven Moreland46e0da72019-09-05 15:52:02 -07001/*
2 * Copyright (C) 2019 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include <iostream>
18#include <sstream>
19#include <string>
20#include <vector>
21
22#ifndef FUZZ_LOG_TAG
23#error "Must define FUZZ_LOG_TAG"
24#endif
25
26#define ENABLE_LOG_FUZZ 1
27#define FUZZ_LOG() FuzzLog(FUZZ_LOG_TAG, ENABLE_LOG_FUZZ).log()
28
29class FuzzLog {
30public:
31 FuzzLog(const std::string& tag, bool log) : mTag(tag), mLog(log) {}
32 ~FuzzLog() {
33 if (mLog) {
34 std::cout << mTag << ": " << mOs.str() << std::endl;
35 }
36 }
37
38 std::stringstream& log() {
39 return mOs;
40 }
41
42private:
43 std::string mTag;
44 bool mLog;
45 std::stringstream mOs;
46};
47
48std::string hexString(const std::vector<uint8_t>& hash);