mirror of
https://github.com/pocoproject/poco.git
synced 2025-01-19 00:46:03 +01:00
PatternFormatter: add %O format specifier
This commit is contained in:
parent
f18ee10a3c
commit
53391151d1
@ -45,6 +45,7 @@ class Foundation_API PatternFormatter: public Formatter
|
||||
/// * %I - message thread identifier (numeric)
|
||||
/// * %N - node or host name
|
||||
/// * %U - message source file path (empty string if not set)
|
||||
/// * %O - message source file filename (empty string if not set)
|
||||
/// * %u - message source line number (0 if not set)
|
||||
/// * %w - message date/time abbreviated weekday (Mon, Tue, ...)
|
||||
/// * %W - message date/time full weekday (Monday, Tuesday, ...)
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "Poco/Environment.h"
|
||||
#include "Poco/NumberParser.h"
|
||||
#include "Poco/StringTokenizer.h"
|
||||
#include "Poco/Path.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
@ -81,6 +82,7 @@ void PatternFormatter::format(const Message& msg, std::string& text)
|
||||
case 'I': NumberFormatter::append(text, msg.getTid()); break;
|
||||
case 'N': text.append(Environment::nodeName()); break;
|
||||
case 'U': text.append(msg.getSourceFile() ? msg.getSourceFile() : ""); break;
|
||||
case 'O': text.append(msg.getSourceFile() ? Path(msg.getSourceFile()).getFileName() : ""); break;
|
||||
case 'u': NumberFormatter::append(text, msg.getSourceLine()); break;
|
||||
case 'w': text.append(DateTimeFormat::WEEKDAY_NAMES[dateTime.dayOfWeek()], 0, 3); break;
|
||||
case 'W': text.append(DateTimeFormat::WEEKDAY_NAMES[dateTime.dayOfWeek()]); break;
|
||||
|
@ -42,6 +42,7 @@ void PatternFormatterTest::testPatternFormatter()
|
||||
msg.setThread("TestThread");
|
||||
msg.setPriority(Message::PRIO_ERROR);
|
||||
msg.setTime(DateTime(2005, 1, 1, 14, 30, 15, 500).timestamp());
|
||||
msg.setSourceFile(__FILE__);
|
||||
msg["testParam"] = "Test Parameter";
|
||||
|
||||
std::string result;
|
||||
|
Loading…
x
Reference in New Issue
Block a user