blob: e5c8ab9b2b00412e92f7b04932f86ebdb9974cc2 [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
Shawn McCarney9af85552020-04-09 11:43:48 -050039/**
40 * Mock journal messages with a priority value of 'DEBUG'.
41 */
42static std::vector<std::string> debugMessages{};
43
Shawn McCarney7c5d7b22020-04-03 18:50:13 -050044void clear()
45{
46 errMessages.clear();
47 infoMessages.clear();
Shawn McCarney9af85552020-04-09 11:43:48 -050048 debugMessages.clear();
Shawn McCarney7c5d7b22020-04-03 18:50:13 -050049}
50
51const std::vector<std::string>& getErrMessages()
52{
53 return errMessages;
54}
55
56const std::vector<std::string>& getInfoMessages()
57{
58 return infoMessages;
59}
60
Shawn McCarney9af85552020-04-09 11:43:48 -050061const std::vector<std::string>& getDebugMessages()
62{
63 return debugMessages;
64}
65
Shawn McCarney7c5d7b22020-04-03 18:50:13 -050066void logErr(const std::string& message)
67{
68 errMessages.emplace_back(message);
69}
70
71void logInfo(const std::string& message)
72{
73 infoMessages.emplace_back(message);
74}
75
Shawn McCarney9af85552020-04-09 11:43:48 -050076void logDebug(const std::string& message)
77{
78 debugMessages.emplace_back(message);
79}
80
Shawn McCarney7c5d7b22020-04-03 18:50:13 -050081} // namespace phosphor::power::regulators::journal