log-manager: enable non-standard path for local tests
Enable the log-manager to be launched with a path other than
`/var/phosphor-logging` to allow it to be ran on a development system
for test purposes. This required some refactoring throughout as to
how paths were handled.
Tested:
After running tests, `/tmp/phosphor-logging` is populated with
entries. Launching `./builddir/phosphor-log-manager
/tmp/phosphor-logging`, the log-manager will have the entries on
dbus:
```
$ busctl --user tree xyz.openbmc_project.Logging
└─ /xyz
└─ /xyz/openbmc_project
└─ /xyz/openbmc_project/logging
├─ /xyz/openbmc_project/logging/entry
│ ├─ /xyz/openbmc_project/logging/entry/100
│ ├─ /xyz/openbmc_project/logging/entry/101
│ ├─ /xyz/openbmc_project/logging/entry/102
│ ├─ /xyz/openbmc_project/logging/entry/103
```
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I84968edeed0dcf73aaf8bb653060b6d3400b9b7b
diff --git a/extensions/openpower-pels/pel_paths.cpp b/extensions/openpower-pels/pel_paths.cpp
new file mode 100644
index 0000000..6ea4219
--- /dev/null
+++ b/extensions/openpower-pels/pel_paths.cpp
@@ -0,0 +1,65 @@
+/**
+ * Copyright © 2019 IBM Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "config.h"
+
+#include "paths.hpp"
+
+#include <filesystem>
+
+namespace openpower
+{
+namespace pels
+{
+
+namespace fs = std::filesystem;
+static constexpr size_t defaultRepoSize = 20 * 1024 * 1024;
+static constexpr size_t defaultMaxNumPELs = 3000;
+
+fs::path getPELIDFile()
+{
+ fs::path logIDPath{phosphor::logging::paths::extension()};
+ logIDPath /= fs::path{"pels"} / fs::path{"pelID"};
+ return logIDPath;
+}
+
+fs::path getPELRepoPath()
+{
+ std::filesystem::path repoPath{phosphor::logging::paths::extension()};
+ repoPath /= "pels";
+ return repoPath;
+}
+
+fs::path getPELReadOnlyDataPath()
+{
+ return std::filesystem::path{"/usr/share/phosphor-logging/pels"};
+}
+
+size_t getPELRepoSize()
+{
+ // For now, always use 20MB, revisit in the future if different
+ // systems need different values so that we only put PEL
+ // content into configure.ac when absolutely necessary.
+ return defaultRepoSize;
+}
+
+size_t getMaxNumPELs()
+{
+ // Hardcode using the same reasoning as the repo size field.
+ return defaultMaxNumPELs;
+}
+
+} // namespace pels
+} // namespace openpower