]>
git.proxmox.com Git - ceph.git/blob - ceph/src/common/subsys_types.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2018 Red Hat Inc.
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
15 #ifndef CEPH_SUBSYS_TYPES_H
16 #define CEPH_SUBSYS_TYPES_H
21 enum ceph_subsys_id_t
{
22 ceph_subsys_
, // default
23 #define SUBSYS(name, log, gather) \
25 #define DEFAULT_SUBSYS(log, gather)
26 #include "common/subsys.h"
32 constexpr static std::size_t ceph_subsys_get_num() {
33 return static_cast<std::size_t>(ceph_subsys_max
);
36 struct ceph_subsys_item_t
{
42 constexpr static std::array
<ceph_subsys_item_t
, ceph_subsys_get_num()>
43 ceph_subsys_get_as_array() {
44 #define SUBSYS(name, log, gather) \
45 ceph_subsys_item_t{ #name, log, gather },
46 #define DEFAULT_SUBSYS(log, gather) \
47 ceph_subsys_item_t{ "none", log, gather },
50 #include "common/subsys.h"
56 constexpr static std::uint8_t
57 ceph_subsys_get_max_default_level(const std::size_t subidx
) {
58 const auto item
= ceph_subsys_get_as_array()[subidx
];
59 return std::max(item
.log_level
, item
.gather_level
);
62 // Compile time-capable version of std::strlen. Resorting to own
63 // implementation only because C++17 doesn't mandate constexpr
64 // on the standard one.
65 constexpr static std::size_t strlen_ct(const char* const s
) {
67 while (s
[l
] != '\0') {
73 constexpr static std::size_t ceph_subsys_max_name_length() {
75 #define SUBSYS(name, log, gather) \
77 #define DEFAULT_SUBSYS(log, gather) \
79 #include "common/subsys.h"
85 #endif // CEPH_SUBSYS_TYPES_H