/src/osquery/plugins/logger/stdout.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /** |
2 | | * Copyright (c) 2014-present, The osquery authors |
3 | | * |
4 | | * This source code is licensed as defined by the LICENSE file found in the |
5 | | * root directory of this source tree. |
6 | | * |
7 | | * SPDX-License-Identifier: (Apache-2.0 OR GPL-2.0-only) |
8 | | */ |
9 | | |
10 | | #include "stdout.h" |
11 | | |
12 | | #include <iostream> |
13 | | |
14 | | #include <osquery/core/flags.h> |
15 | | #include <osquery/logger/logger.h> |
16 | | |
17 | | namespace osquery { |
18 | | |
19 | 0 | Status StdoutLoggerPlugin::logString(const std::string& s) { |
20 | 0 | std::cout << s << std::endl; |
21 | 0 | return Status(); |
22 | 0 | } |
23 | | |
24 | 0 | Status StdoutLoggerPlugin::logStatus(const std::vector<StatusLogLine>& log) { |
25 | 0 | for (const auto& item : log) { |
26 | 0 | std::string line = "severity=" + std::to_string(item.severity) + |
27 | 0 | " location=" + item.filename + ":" + |
28 | 0 | std::to_string(item.line) + " message=" + item.message; |
29 | 0 | std::cout << line << std::endl; |
30 | 0 | } |
31 | 0 | return Status(); |
32 | 0 | } |
33 | | |
34 | | void StdoutLoggerPlugin::init(const std::string& name, |
35 | 0 | const std::vector<StatusLogLine>& log) { |
36 | | // Stop the internal Glog facilities. |
37 | 0 | FLAGS_alsologtostderr = false; |
38 | 0 | FLAGS_logtostderr = false; |
39 | 0 | FLAGS_stderrthreshold = 5; |
40 | | |
41 | | // Now funnel the intermediate status logs provided to `init`. |
42 | 0 | logStatus(log); |
43 | 0 | } |
44 | | } |