Line data Source code
1 : #pragma once 2 : 3 : #include "envoy/access_log/access_log_config.h" 4 : 5 : #include "source/common/formatter/substitution_format_string.h" 6 : #include "source/common/formatter/substitution_formatter.h" 7 : #include "source/extensions/access_loggers/common/file_access_log_impl.h" 8 : 9 : namespace Envoy { 10 : namespace Extensions { 11 : namespace AccessLoggers { 12 : 13 : template <class T, Filesystem::DestinationType destination_type> 14 : AccessLog::InstanceSharedPtr 15 : createStreamAccessLogInstance(const Protobuf::Message& config, AccessLog::FilterPtr&& filter, 16 0 : Server::Configuration::FactoryContext& context) { 17 0 : const auto& fal_config = 18 0 : MessageUtil::downcastAndValidate<const T&>(config, context.messageValidationVisitor()); 19 0 : Formatter::FormatterPtr formatter; 20 0 : if (fal_config.access_log_format_case() == T::AccessLogFormatCase::kLogFormat) { 21 0 : formatter = 22 0 : Formatter::SubstitutionFormatStringUtils::fromProtoConfig(fal_config.log_format(), context); 23 0 : } else if (fal_config.access_log_format_case() == 24 0 : T::AccessLogFormatCase::ACCESS_LOG_FORMAT_NOT_SET) { 25 0 : formatter = Formatter::HttpSubstitutionFormatUtils::defaultSubstitutionFormatter(); 26 0 : } 27 0 : Filesystem::FilePathAndType file_info{destination_type, ""}; 28 0 : return std::make_shared<AccessLoggers::File::FileAccessLog>( 29 0 : file_info, std::move(filter), std::move(formatter), 30 0 : context.serverFactoryContext().accessLogManager()); 31 0 : } 32 : 33 : } // namespace AccessLoggers 34 : } // namespace Extensions 35 : } // namespace Envoy