Files
o3de/Code/Tools/AWSNativeSDKInit/include/AWSNativeSDKInit/AWSLogSystemInterface.h
T
2021-06-23 10:55:22 -07:00

77 lines
2.1 KiB
C++

/*
* Copyright (c) Contributors to the Open 3D Engine Project
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#if defined(PLATFORM_SUPPORTS_AWS_NATIVE_SDK)
#include <AzCore/PlatformDef.h>
AZ_PUSH_DISABLE_WARNING(4251 4996, "-Wunknown-warning-option")
#include <aws/core/utils/logging/LogSystemInterface.h>
AZ_POP_DISABLE_WARNING
#else
#include <sstream>
namespace Aws
{
using OStringStream = std::basic_ostringstream<char>;
namespace Utils
{
namespace Logging
{
using LogLevel = int;
}
}
}
#endif
namespace AWSNativeSDKInit
{
class AWSLogSystemInterface
#if defined(PLATFORM_SUPPORTS_AWS_NATIVE_SDK)
: public Aws::Utils::Logging::LogSystemInterface
#endif
{
public:
static const char* AWS_API_LOG_PREFIX;
static const int MAX_MESSAGE_LENGTH;
static const char* MESSAGE_FORMAT;
static const char* ERROR_WINDOW_NAME;
static const char* LOG_ENV_VAR;
AWSLogSystemInterface(Aws::Utils::Logging::LogLevel logLevel);
/**
* Gets the currently configured log level for this logger.
*/
#if defined(PLATFORM_SUPPORTS_AWS_NATIVE_SDK)
Aws::Utils::Logging::LogLevel GetLogLevel(void) const override;
#else
Aws::Utils::Logging::LogLevel GetLogLevel(void) const;
#endif
/**
* Does a printf style output to the output stream. Don't use this, it's unsafe. See LogStream
*/
void Log(Aws::Utils::Logging::LogLevel logLevel, const char* tag, const char* formatStr, ...);
/**
* Writes the stream to the output stream.
*/
void LogStream(Aws::Utils::Logging::LogLevel logLevel, const char* tag, const Aws::OStringStream &messageStream);
void Flush();
private:
bool ShouldLog(Aws::Utils::Logging::LogLevel logLevel);
void SetLogLevel(Aws::Utils::Logging::LogLevel newLevel);
void ForwardAwsApiLogMessage(Aws::Utils::Logging::LogLevel logLevel, const char* tag, const char* message);
Aws::Utils::Logging::LogLevel m_logLevel;
};
}