|
|
@@ -17,18 +17,31 @@ using namespace logging;
|
|
|
struct pattern_layout : public layout {
|
|
|
static std::shared_ptr<layout> create(properties const &);
|
|
|
|
|
|
- pattern_layout(std::string const & fmt);
|
|
|
+ pattern_layout(properties const & props);
|
|
|
std::string format(logpacket const & pkt) const override;
|
|
|
|
|
|
class format formatter;
|
|
|
};
|
|
|
|
|
|
+using namespace logging::property;
|
|
|
+properties const DEFAULT_PATTERN_LAYOUT{_obj({
|
|
|
+ {"charset", _v("en_US.UTF-8")},
|
|
|
+ {"pattern", {}},
|
|
|
+ {"patternSelector", {}},
|
|
|
+ {"replace", _v("")},
|
|
|
+ {"header", _v("")},
|
|
|
+ {"footer", _v("")},
|
|
|
+ {"disableAnsi", _v(false)},
|
|
|
+ {"noConsoleNoAnsi", _v(false)}
|
|
|
+})};
|
|
|
+
|
|
|
std::shared_ptr<layout> pattern_layout::create(properties const & props) {
|
|
|
- return std::make_shared<pattern_layout>(props["pattern"]);
|
|
|
+ properties const actual = DEFAULT_PATTERN_LAYOUT.mergedWith(props);
|
|
|
+ return std::make_shared<pattern_layout>(actual);
|
|
|
}
|
|
|
|
|
|
-pattern_layout::pattern_layout(std::string const & fmt) :
|
|
|
- formatter(format::parse_format_string(fmt)) {}
|
|
|
+pattern_layout::pattern_layout(properties const & props) :
|
|
|
+ formatter(format::parse_format_string(props["pattern"])) {}
|
|
|
|
|
|
std::string pattern_layout::format(logpacket const & pkt) const {
|
|
|
return formatter.process(pkt);
|