Debian Codegraph @

crt/aws-c-common/tests/logging/test_logger.h

raw symbols SCIP
1 /* NOLINTNEXTLINE(llvm-header-guard) */
2 #ifndef AWS_COMMON_TEST_LOGGER_H
3 #define AWS_COMMON_TEST_LOGGER_H
4
5 /**
6 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
7 * SPDX-License-Identifier: Apache-2.0.
8 */
9
10 #include <aws/common/logging.h>
11
12 #include <aws/common/byte_buf.h>
13
14 /**
15 * The test logger is a simple forwarding logger that just records what was passed to it.
16 * We provide an extraction function for easy test validation.
17 */
18 struct test_logger_impl {
19 enum aws_log_level level;
20 struct aws_byte_buf log_buffer;
21 size_t max_size;
22 };
23
24 /**
25 * Given a pointer to a logger, initializes it as a test logger using the supplied log level.
26 * max_size of 0 is unlimited
27 */
28 int test_logger_init(
29 struct aws_logger *logger,
30 struct aws_allocator *allocator,
31 enum aws_log_level level,
32 size_t max_size);
33
34 /**
35 * Extracts logged content from a test logger.
36 */
37 int test_logger_get_contents(struct aws_logger *logger, char *buffer, size_t max_length);
38
39 #endif /* AWS_COMMON_TEST_LOGGER_H */