2024-01-17 00:28:20 -06:00
|
|
|
// MIT License
|
|
|
|
|
//
|
|
|
|
|
// Copyright (c) 2023 Advanced Micro Devices, Inc.
|
|
|
|
|
//
|
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
|
// of this software and associated documentation files (the "Software"), to deal
|
|
|
|
|
// in the Software without restriction, including without limitation the rights
|
|
|
|
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
|
// copies of the Software, and to permit persons to whom the Software is
|
|
|
|
|
// furnished to do so, subject to the following conditions:
|
|
|
|
|
//
|
|
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
|
// all copies or substantial portions of the Software.
|
|
|
|
|
//
|
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
|
// THE SOFTWARE.
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2024-03-07 22:21:26 -06:00
|
|
|
#include <glog/logging.h>
|
|
|
|
|
|
|
|
|
|
#include <cstdint>
|
2024-01-17 00:28:20 -06:00
|
|
|
#include <string_view>
|
|
|
|
|
|
2024-04-02 17:15:30 -07:00
|
|
|
#define ROCP_LEVEL_TRACE 12
|
|
|
|
|
#define ROCP_LEVEL_INFO 11
|
|
|
|
|
#define ROCP_LEVEL_WARNING 10
|
|
|
|
|
#define ROCP_NO_VLOG -1
|
|
|
|
|
|
|
|
|
|
#define ROCP_TRACE VLOG(ROCP_LEVEL_TRACE)
|
|
|
|
|
#define ROCP_INFO VLOG(ROCP_LEVEL_INFO)
|
|
|
|
|
#define ROCP_WARNING VLOG(ROCP_LEVEL_WARNING)
|
|
|
|
|
#define ROCP_ERROR LOG(ERROR)
|
|
|
|
|
#define ROCP_FATAL LOG(FATAL)
|
|
|
|
|
#define ROCP_DFATAL DLOG(FATAL)
|
|
|
|
|
|
2024-01-17 00:28:20 -06:00
|
|
|
namespace rocprofiler
|
|
|
|
|
{
|
|
|
|
|
namespace common
|
|
|
|
|
{
|
2024-03-07 22:21:26 -06:00
|
|
|
struct logging_config
|
|
|
|
|
{
|
|
|
|
|
bool install_failure_handler = false;
|
|
|
|
|
bool logtostderr = true;
|
|
|
|
|
bool alsologtostderr = false;
|
2024-04-02 17:15:30 -07:00
|
|
|
int32_t vlog_level = ROCP_NO_VLOG;
|
2024-03-07 22:21:26 -06:00
|
|
|
int32_t loglevel = google::WARNING;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
init_logging(std::string_view env_var, logging_config cfg = logging_config{});
|
|
|
|
|
|
2024-01-17 00:28:20 -06:00
|
|
|
void
|
2024-03-07 22:21:26 -06:00
|
|
|
update_logging(const logging_config& cfg, bool setup_env = false, int env_override = 0);
|
|
|
|
|
} // namespace common
|
2024-01-17 00:28:20 -06:00
|
|
|
} // namespace rocprofiler
|