Flow 1.0.2
Flow project: Full implementation reference.
log_component_enum_declare.macros.hpp
Go to the documentation of this file.
1/* Flow
2 * Copyright 2023 Akamai Technologies, Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the
5 * "License"); you may not use this file except in
6 * compliance with the License. You may obtain a copy
7 * of the License at
8 *
9 * https://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in
12 * writing, software distributed under the License is
13 * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
14 * CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing
16 * permissions and limitations under the License. */
17
18/// @file
19
20/// @cond
21// -^- Doxygen, please ignore the following. This is wacky macro magic and not a regular `#pragma once` header.
22
23/* See common.hpp and common.cpp which #include us.
24 * Long story short, the following macro invocations directly or indirectly specify:
25 * - each enum variable name of `enum class Flow_log_component`, the Component payload enum used by Flow log messages
26 * themselves (`S_` is auto-prepended to each name);
27 * - for each enum variable name, its numeric counterpart;
28 * - for each enum variable name, its string version for output and config-specification purposes (the name is
29 * auto-derived from variable name via the # macro operator).
30 *
31 * Requirements:
32 * - The numeric values must appear in ascending order (even though gaps are allowed; see below).
33 * - Technically, all that's really required is that the last one mentioned is the one with the highest numeric
34 * value, but just keep them in order, period.
35 * - Be aware that the `enum` member `S_END_SENTINEL` will be auto-appended, and its numeric value will equal
36 * that of the last (and highest) numeric value you specify, plus 1. This is used by certain flow::log utilities,
37 * but we suppose the user might use it too (unlikely as it is).
38 * - Obviously you cannot declare one named `END_SENTINEL`, as a result. Informally, you should also not add
39 * your own end sentinel member.
40 *
41 * A few common-sense reminders for convenience:
42 * - Do not prepend a namespace-like prefix to each var name. In code, the enum class name will serve that role.
43 * In log output, the Config API allows one to specify a prefix applied to all enum member names, at runtime.
44 * In config specifications, ditto. So don't worry that <your enum>::S_UTIL will in any way clash with
45 * <some other enum>::S_UTIL.
46 * - It is conventional (but not mandatory) to have (UNCAT, 0) be the first entry, representing "uncategorized" or
47 * "general." It is also conventional to start with 0 and not a higher number. Only unsigned are supported.
48 * - Numeric gaps are allowed but discouraged, unless there's a great reason (typically to do with backwards
49 * compatibility and component deprecation -- in author's experience).
50 * - The same number can correspond to 2+ enum members. This is discouraged, unless there's a great reason
51 * (typically historic -- in author's experience). If this is the case, then:
52 * - Verbosity X specified for any 1 of the 2+ enum members will apply to all 2+ of them. In other words, all 2+
53 * components are really one, in a way, linked together by their common number.
54 * - String output of such a component will be a comma-separated list of all 2+ enum names. If numeric output
55 * is configured instead, then by definition it will print the 1 number shared by 2+ enum names.
56 * - Any one of the 2+ names can be used in code and config to specify the component. However, again, the effect
57 * will be as per the previous 2 bullet points. */
58
59// Rarely used component corresponding to log call sites outside namespace `flow::X`, for all X in `flow`.
60FLOW_LOG_CFG_COMPONENT_DEFINE(UNCAT, 0)
61// Logging from namespace flow::log.
62FLOW_LOG_CFG_COMPONENT_DEFINE(LOG, 1)
63// Logging from namespace flow::error.
64FLOW_LOG_CFG_COMPONENT_DEFINE(ERROR, 2)
65// Logging from namespace flow::util.
66FLOW_LOG_CFG_COMPONENT_DEFINE(UTIL, 3)
67// Logging from namespace flow::async.
68FLOW_LOG_CFG_COMPONENT_DEFINE(ASYNC, 4)
69// Logging from namespace flow::perf.
70FLOW_LOG_CFG_COMPONENT_DEFINE(PERF, 5)
71// Logging from namespace flow::net_flow, when the following more-specific components don't apply.
72FLOW_LOG_CFG_COMPONENT_DEFINE(NET_FLOW, 6)
73// Logging from namespace flow::net_flow::asio, which integrates flow::net_flow sockets with boost.asio.
74FLOW_LOG_CFG_COMPONENT_DEFINE(NET_FLOW_ASIO, 7)
75// Logging from namespace flow::net_flow, in congestion control-related code.
76FLOW_LOG_CFG_COMPONENT_DEFINE(NET_FLOW_CC, 8)
77// Logging from namespace flow::cfg.
78FLOW_LOG_CFG_COMPONENT_DEFINE(CFG, 9)
79
80// -v- Doxygen, please stop ignoring.
81/// @endcond