Program Listing for File tag.h

↰ Return to documentation for file (/home/docs/checkouts/readthedocs.org/user_builds/canonical-mir-documentation/checkouts/2.30/include/core/mir/logging/tag.h)

/*
 * Copyright © Canonical Ltd.
 *
 * This program is free software: you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License version 2 or 3,
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef MIR_LOGGING_TAG_H_
#define MIR_LOGGING_TAG_H_

#include <format>
#include <functional>
#include <initializer_list>
#include <string_view>
#include <vector>

namespace mir::logging
{
struct Tag;
Tag const& create_tag(Tag const& parent, std::string_view name);

Tag const& base();
Tag const& input();
Tag const& wayland();
Tag const& graphics();
Tag const& window_management();

using Tags = std::initializer_list<std::reference_wrapper<Tag const> const>;

enum class Severity
{
    critical = 0,
    error = 1,
    warning = 2,
    informational = 3,
    debug = 4
};

auto parse_severity(std::string_view severity_name) -> Severity;

auto logging_enabled_for(Tag const& tag, Severity sev) -> bool;

auto list_known_tags() -> std::vector<std::string>;

namespace tag
{
auto name(Tag const& tag) -> std::string_view;
auto name(Tag&& tag) -> std::string_view = delete; // A string_view onto a temporary would be bad

void set_severity(std::string_view name, Severity severity);
}
}

template<>
struct std::formatter<mir::logging::Severity> : std::formatter<std::string>
{
    auto format(mir::logging::Severity sev, std::format_context& ctx) const -> std::format_context::iterator;
};

#endif // MIR_LOGGING_TAG_H_