Shawn McCarney | 7c5d7b2 | 2020-04-03 18:50:13 -0500 | [diff] [blame] | 1 | /** |
| 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 | */ |
| 26 | namespace phosphor::power::regulators::journal |
| 27 | { |
| 28 | |
| 29 | /** |
| 30 | * Mock journal messages with a priority value of 'ERR'. |
| 31 | */ |
| 32 | static std::vector<std::string> errMessages{}; |
| 33 | |
| 34 | /** |
| 35 | * Mock journal messages with a priority value of 'INFO'. |
| 36 | */ |
| 37 | static std::vector<std::string> infoMessages{}; |
| 38 | |
| 39 | void clear() |
| 40 | { |
| 41 | errMessages.clear(); |
| 42 | infoMessages.clear(); |
| 43 | } |
| 44 | |
| 45 | const std::vector<std::string>& getErrMessages() |
| 46 | { |
| 47 | return errMessages; |
| 48 | } |
| 49 | |
| 50 | const std::vector<std::string>& getInfoMessages() |
| 51 | { |
| 52 | return infoMessages; |
| 53 | } |
| 54 | |
| 55 | void logErr(const std::string& message) |
| 56 | { |
| 57 | errMessages.emplace_back(message); |
| 58 | } |
| 59 | |
| 60 | void logInfo(const std::string& message) |
| 61 | { |
| 62 | infoMessages.emplace_back(message); |
| 63 | } |
| 64 | |
| 65 | } // namespace phosphor::power::regulators::journal |