log-handler: Allow configuration of logfile parameter
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
diff --git a/log-handler.c b/log-handler.c
index 9a387fd..79c3a1a 100644
--- a/log-handler.c
+++ b/log-handler.c
@@ -24,7 +24,7 @@
};
-static const char *filename = LOCALSTATEDIR "/log/openbmc-console.log";
+static const char *default_filename = LOCALSTATEDIR "/log/openbmc-console.log";
static const size_t logsize = 16 * 1024;
@@ -37,6 +37,7 @@
struct config *config __attribute__((unused)))
{
struct log_handler *lh = to_log_handler(handler);
+ const char *filename;
int rc;
lh->console = console;
@@ -44,6 +45,10 @@
lh->pagesize = 4096;
lh->size = 0;
+ filename = config_get_value(config, "logfile");
+ if (!filename)
+ filename = default_filename;
+
lh->fd = open(filename, O_RDWR | O_CREAT, 0644);
if (lh->fd < 0) {
warn("Can't open log buffer file %s", filename);