Files
doris/be/src/util/logging.h
Zhengguo Yang 6ede4c6ec1 [Feature] Support backup,restore,load,export directly connect to s3 (#5399)
* [doris-1008] support backup and restore directly to cloud storage via aws s3 protocol

* Internal][S3DirectAccess] Support backup,restore,load,export directlyconnect to s3
1. Support load and export data from/to s3 directly.
2. Add a config to auto convert broker access to s3 acces when available

Change-Id: Iac96d4b3670776708bc96a119ff491db8cb4cde7

(cherry picked from commit 2f03832ca52221cc7436069b96c45c48c4bc7201)

* [Internal][S3DirectAccess] File path glob compatible with broker

Change-Id: Ie55e07a547aa22c6fa8d432ca926216c10384e68
(cherry picked from commit d4fb25544c0dc06d23e1ada571ec3f8edd4ba56f)

* [internal] [doris-1008] fix log4j class not found

Change-Id: I468176aca0d821383c74ee658d461aba9e7d5be3
(cherry picked from commit 029adaa9d6ded8503acbd6644c1519456f3db232)

* add poms

Co-authored-by: yangzhengguo01 <yangzhengguo01@baidu.com>
2021-02-22 16:07:56 +08:00

94 lines
3.5 KiB
C++

// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
#ifndef DORIS_BE_SRC_COMMON_UTIL_LOGGING_H
#define DORIS_BE_SRC_COMMON_UTIL_LOGGING_H
#include <aws/core/utils/logging/LogLevel.h>
#include <aws/core/utils/logging/LogSystemInterface.h>
#include <atomic>
#include <string>
#include "common/logging.h"
#include "gutil/walltime.h"
namespace doris {
// glog doesn't allow multiple invocations of InitGoogleLogging. This method conditionally
// calls InitGoogleLogging only if it hasn't been called before.
bool init_glog(const char* basename, bool install_signal_handler = false);
// Shuts down the google logging library. Call before exit to ensure that log files are
// flushed. May only be called once.
void shutdown_logging();
// Format a timestamp in the same format as used by GLog.
std::string FormatTimestampForLog(MicrosecondsInt64 micros_since_epoch);
class DorisAWSLogger final : public Aws::Utils::Logging::LogSystemInterface {
public:
DorisAWSLogger() : _log_level(Aws::Utils::Logging::LogLevel::Info) {}
DorisAWSLogger(Aws::Utils::Logging::LogLevel log_level) : _log_level(log_level) {}
~DorisAWSLogger() final = default;
Aws::Utils::Logging::LogLevel GetLogLevel() const final { return _log_level; }
void Log(Aws::Utils::Logging::LogLevel log_level, const char* tag, const char* format_str,
...) final {
_log_impl(log_level, tag, format_str);
}
void LogStream(Aws::Utils::Logging::LogLevel log_level, const char* tag,
const Aws::OStringStream& message_stream) final {
_log_impl(log_level, tag, message_stream.str().c_str());
}
void Flush() final {}
private:
void _log_impl(Aws::Utils::Logging::LogLevel log_level, const char* tag, const char* message) {
switch (log_level) {
case Aws::Utils::Logging::LogLevel::Off:
break;
case Aws::Utils::Logging::LogLevel::Fatal:
LOG(FATAL) << "[" << tag << "] " << message;
break;
case Aws::Utils::Logging::LogLevel::Error:
LOG(ERROR) << "[" << tag << "] " << message;
break;
case Aws::Utils::Logging::LogLevel::Warn:
LOG(WARNING) << "[" << tag << "] " << message;
break;
case Aws::Utils::Logging::LogLevel::Info:
LOG(INFO) << "[" << tag << "] " << message;
break;
case Aws::Utils::Logging::LogLevel::Debug:
VLOG_ROW << "[" << tag << "] " << message;
break;
case Aws::Utils::Logging::LogLevel::Trace:
VLOG_ROW << "[" << tag << "] " << message;
break;
default:
break;
}
}
std::atomic<Aws::Utils::Logging::LogLevel> _log_level;
};
} // namespace doris
#endif // DORIS_BE_SRC_COMMON_UTIL_LOGGING_H