iceberg-cpp
Loading...
Searching...
No Matches
loggers.h
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20#pragma once
21
24
25#include <functional>
26#include <memory>
27#include <string>
28#include <string_view>
29#include <unordered_map>
30
33#include "iceberg/result.h"
34
35namespace iceberg {
36
38constexpr std::string_view kLoggerImpl = "logger-impl";
40constexpr std::string_view kLoggerTypeNoop = "noop";
41constexpr std::string_view kLoggerTypeCerr = "cerr";
42constexpr std::string_view kLoggerTypeSpdlog = "spdlog";
43
45using LoggerFactory = std::function<Result<std::unique_ptr<Logger>>(
46 const std::unordered_map<std::string, std::string>& properties)>;
47
54class ICEBERG_EXPORT Loggers {
55 public:
58 const std::unordered_map<std::string, std::string>& properties);
59
61 static Status Register(std::string_view logger_type, LoggerFactory factory);
62};
63
64} // namespace iceberg
Registry of logger factories, mirroring MetricsReporters.
Definition loggers.h:54
static Status Register(std::string_view logger_type, LoggerFactory factory)
Register a factory for logger_type (overwrites any existing).
static Result< std::unique_ptr< Logger > > Load(const std::unordered_map< std::string, std::string > &properties)
Construct and initialize a logger from properties.
Define symbol visibility macros for core Iceberg APIs.
Pluggable logging interface and the process-global default logger.
Core Apache Iceberg C++ APIs.
Definition arrow_io_util.h:33
std::function< Result< std::unique_ptr< Logger > >(const std::unordered_map< std::string, std::string > &properties)> LoggerFactory
Factory constructing a Logger from catalog-style properties.
Definition loggers.h:46
constexpr std::string_view kLoggerTypeNoop
Built-in logger type identifiers.
Definition loggers.h:40
constexpr std::string_view kLoggerImpl
Property key selecting the logger implementation.
Definition loggers.h:38
std::expected< T, E > Result
Result alias.
Definition result.h:88
Define Result, Status, and error helpers.