diff options
author | Krzysztof Jackiewicz <k.jackiewicz@samsung.com> | 2015-01-28 10:19:38 +0100 |
---|---|---|
committer | Maciej J. Karpiuk <m.karpiuk2@samsung.com> | 2015-02-17 12:09:37 +0100 |
commit | ef12755a0563f493acb6e74526d7770ffec39cd9 (patch) | |
tree | 9e0212ab18a985bcf5a340605bee22147f89b561 /src/manager/dpl | |
parent | 66d9244c4134c4437bfb675d93f5b1627a1a6986 (diff) | |
download | key-manager-ef12755a0563f493acb6e74526d7770ffec39cd9.tar.gz key-manager-ef12755a0563f493acb6e74526d7770ffec39cd9.tar.bz2 key-manager-ef12755a0563f493acb6e74526d7770ffec39cd9.zip |
Add file, line & function information to journald log
[Issue#] N/A
[Feature/Bug] N/A
[Problem] File, line & function not visible in default journalctl log
[Cause] Default log format does not display this information and other formats
are unreadable
[Solution] File, line & function information added to log message content
[Verification] Create /etc/sysconfig/central-key-manager with following content
"
CKM_LOG_LEVEL=3
CKM_LOG_PROVIDER=JOURNALD
"
Restart the service and see if journalctl logs contain file, line & function
info:
journalctl -f -u central-key-manager
Change-Id: I01389eda9f7db390f6ca00c8f44e1a5c097e59c8
Diffstat (limited to 'src/manager/dpl')
-rw-r--r-- | src/manager/dpl/log/src/journal_log_provider.cpp | 25 | ||||
-rw-r--r-- | src/manager/dpl/log/src/log.cpp | 8 |
2 files changed, 22 insertions, 11 deletions
diff --git a/src/manager/dpl/log/src/journal_log_provider.cpp b/src/manager/dpl/log/src/journal_log_provider.cpp index b298b79e..8f7af576 100644 --- a/src/manager/dpl/log/src/journal_log_provider.cpp +++ b/src/manager/dpl/log/src/journal_log_provider.cpp @@ -52,18 +52,21 @@ void JournalLogProvider::Log(AbstractLogProvider::LogLevel level, { try { sd_journal_send("PRIORITY=%d", journalLevel.at(level), - "CODE_FILE=%s", fileName, - "CODE_FUNC=%s", function, - "CODE_LINE=%d", line, - "MESSAGE=%s", message, - NULL); + "CODE_FILE=%s", fileName, + "CODE_FUNC=%s", function, + "CODE_LINE=%d", line, + // add file, line & function info to log message + "MESSAGE=[%s:%d] %s(): %s", fileName, line, function, message, + NULL); } catch (const std::out_of_range&) { - sd_journal_send("PRIORITY=%d", LOG_ERR, - "CODE_FILE=%s", fileName, - "CODE_FUNC=%s", function, - "CODE_LINE=%d", line, - "MESSAGE=Unsupported log level %d", level, - NULL); + sd_journal_send( + "PRIORITY=%d", LOG_ERR, + "CODE_FILE=%s", fileName, + "CODE_FUNC=%s", function, + "CODE_LINE=%d", line, + // add file, line & function info to log message + "MESSAGE=[%s:%d] %s(): Unsupported log level %d", fileName, line, function, level, + NULL); } } diff --git a/src/manager/dpl/log/src/log.cpp b/src/manager/dpl/log/src/log.cpp index 5bfaacba..6b5b8a1e 100644 --- a/src/manager/dpl/log/src/log.cpp +++ b/src/manager/dpl/log/src/log.cpp @@ -39,6 +39,14 @@ namespace CKM { namespace Log { namespace // anonymous { +/* + * Set these variables to desired values in /etc/sysconfig/central-key-manager and restart + * central-key-manager service to use them. + * + * Example: + * CKM_LOG_LEVEL=3 + * CKM_LOG_PROVIDER=JOURNALD + */ const char * const CKM_LOG_LEVEL = "CKM_LOG_LEVEL"; const char * const CKM_LOG_PROVIDER = "CKM_LOG_PROVIDER"; |