diff options
author | Adriana Kobylak <anoo@us.ibm.com> | 2016-09-29 20:48:08 -0500 |
---|---|---|
committer | Andrew Geissler <andrewg@us.ibm.com> | 2016-10-31 11:51:50 -0500 |
commit | f855c3e54f2c06da0649a7dfc31f60d7a36bcd6f (patch) | |
tree | 37e86614d241245fc20eb45027e02b211d957517 /test | |
parent | 91da45310b8ba4d244ec0d9036c9e104d1b9f7c4 (diff) | |
download | phosphor-logging-f855c3e54f2c06da0649a7dfc31f60d7a36bcd6f.tar.gz phosphor-logging-f855c3e54f2c06da0649a7dfc31f60d7a36bcd6f.zip |
Error / Event Log Framework
Framework to create an error log entry based on information
from the journal log.
1. elog.yaml - User defined reason codes for error scenarios that
include description, priority level, and desired metadata fields.
2. elog_parser.py - Parser for the yaml file
3. elog-gen.hpp - Auto-generated file based created by the parser
that includes the error log structures. Including for now for ref.
4. elog.hpp - Error log template to create (log a journal log
entry with the predefined error log information).
Usage: elog<RC>(NAME(value), prev_entry<NAME>()...)
where RC - Reason code, NAME - metadata name
being logged to a journal entry, prev_entry - A Metadata entry that
has previously being logged to a journal entry.
Example:
log<level::DEBUG>(
msg("Info trace to log filename"),
entry(file_not_found::file_name::str, my_filename));
elog<file_not_found>(file_not_found::errnum(2),
file_not_found::file_path("/tmp/"),
prev_entry<file_not_found::file_name>());
Change-Id: Ic51cee80b58e341c071c366c5e2146fd6694012c
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
Signed-off-by: Andrew Geissler <andrewg@us.ibm.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/logging_test.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/test/logging_test.cpp b/test/logging_test.cpp new file mode 100644 index 0000000..2b75854 --- /dev/null +++ b/test/logging_test.cpp @@ -0,0 +1,46 @@ +#include <iostream> +#include "elog.hpp" +#include "log.hpp" + +using namespace phosphor; +using namespace logging; + +int main() +{ + std::cout << "hello world!\n"; + + // Simple elog test + const char *test_string = "/tmp/test_string/"; + elog<file_not_found>(file_not_found::errnum(1), + file_not_found::file_path(test_string), + file_not_found::file_name("elog_test_1.txt")); + + log<level::DEBUG>("Info trace to log file path", + entry(file_not_found::file_path::str, + "/tmp/log_file_test/")); + + // pass parameter and previous_entry + elog<file_not_found>(file_not_found::errnum(2), + prev_entry<file_not_found::file_path>(), + file_not_found::file_name("elog_test_2.txt")); + + // Simple test to prove we fail to compile due to missing param + //elog<file_not_found>(file_not_found::errnum(1), + // file_not_found::file_path("test")); + + // Simple test to prove we fail to compile due to invalid param + //elog<file_not_found>(file_not_found::errnum(1), + // file_not_found::file_path("test"), + // file_not_found::file_name(1)); + + // Log tests + log<level::DEBUG>("Simple Example"); + + const char *file_name = "HELLO.txt"; + int number = 0xFEFE; + + log<level::DEBUG>("THIS IS A PHOSPHOR LOGGING TEST", + entry("FILE_NAME=%s_%x", file_name, number)); + + return 0; +} |