blob: 506b4cc64e4f92203f491eb46b93e4bafac63f8c [file] [log] [blame]
// Copyright 2020 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <lib/syslog/logger.h>
#include <stdarg.h>
#include "namespace.h"
// Provides a driver's logger.
class Logger {
// Creates a logger with a given |name|, which will only send logs that are of
// at least |min_severity|.
static zx::status<Logger> Create(const Namespace& ns, async_dispatcher_t* dispatcher,
std::string_view name,
fx_log_severity_t min_severity = FX_LOG_SEVERITY_DEFAULT);
Logger() = default;
Logger(Logger&& other) noexcept;
Logger& operator=(Logger&& other) noexcept;
// Sends a trace log.
void trace(const char* msg, ...);
// Sends a debug log.
void debug(const char* msg, ...);
// Sends an info log.
void info(const char* msg, ...);
// Sends a warning log.
void warning(const char* msg, ...);
// Sends an error log.
void error(const char* msg, ...);
explicit Logger(fx_logger_t* logger);
Logger(const Logger& other) = delete;
Logger& operator=(const Logger& other) = delete;
void log(fx_log_severity_t severity, const char* msg, va_list args);
fx_logger_t* logger_ = nullptr;