1 // Copyright 2023 gRPC authors.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef GRPC_SRC_CORE_LIB_SECURITY_AUTHORIZATION_STDOUT_LOGGER_H
16 #define GRPC_SRC_CORE_LIB_SECURITY_AUTHORIZATION_STDOUT_LOGGER_H
17 
18 #include <grpc/support/port_platform.h>
19 
20 #include <memory>
21 #include <string>
22 
23 #include "absl/status/statusor.h"
24 #include "absl/strings/string_view.h"
25 
26 #include <grpc/grpc_audit_logging.h>
27 #include <grpc/support/json.h>
28 
29 namespace grpc_core {
30 namespace experimental {
31 
32 class StdoutAuditLogger : public AuditLogger {
33  public:
34   StdoutAuditLogger() = default;
name()35   absl::string_view name() const override { return "stdout_logger"; }
36   void Log(const AuditContext&) override;
37 };
38 
39 class StdoutAuditLoggerFactory : public AuditLoggerFactory {
40  public:
41   class Config : public AuditLoggerFactory::Config {
42    public:
43     Config() = default;
44     absl::string_view name() const override;
45     std::string ToString() const override;
46   };
47   StdoutAuditLoggerFactory() = default;
48 
49   absl::string_view name() const override;
50 
51   absl::StatusOr<std::unique_ptr<AuditLoggerFactory::Config>>
52   ParseAuditLoggerConfig(const Json& json) override;
53 
54   std::unique_ptr<AuditLogger> CreateAuditLogger(
55       std::unique_ptr<AuditLoggerFactory::Config>) override;
56 };
57 
58 }  // namespace experimental
59 }  // namespace grpc_core
60 
61 #endif  // GRPC_SRC_CORE_LIB_SECURITY_AUTHORIZATION_STDOUT_LOGGER_H
62