blob: 2446182e479fe24e9e44cfbc624a46c2b0dfafa9 [file] [log] [blame]
Shawn McCarney7c5d7b22020-04-03 18:50:13 -05001/**
2 * Copyright © 2020 IBM Corporation
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 "mock_journal.hpp"
18
19/**
20 * This is the mock implementation of the journal interface. It just stores the
21 * journal messages in static vectors.
22 *
23 * Executables that need to log real systemd journal messages should link with
24 * the file journal.cpp instead.
25 */
26namespace phosphor::power::regulators::journal
27{
28
29/**
30 * Mock journal messages with a priority value of 'ERR'.
31 */
32static std::vector<std::string> errMessages{};
33
34/**
35 * Mock journal messages with a priority value of 'INFO'.
36 */
37static std::vector<std::string> infoMessages{};
38
39void clear()
40{
41 errMessages.clear();
42 infoMessages.clear();
43}
44
45const std::vector<std::string>& getErrMessages()
46{
47 return errMessages;
48}
49
50const std::vector<std::string>& getInfoMessages()
51{
52 return infoMessages;
53}
54
55void logErr(const std::string& message)
56{
57 errMessages.emplace_back(message);
58}
59
60void logInfo(const std::string& message)
61{
62 infoMessages.emplace_back(message);
63}
64
65} // namespace phosphor::power::regulators::journal