Debian Codegraph @

crt/aws-c-common/include/aws/common/log_channel.h

raw symbols SCIP
1
2 #ifndef AWS_COMMON_LOG_CHANNEL_H
3 #define AWS_COMMON_LOG_CHANNEL_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/common.h>
11
12 #include <aws/common/logging.h>
13
14 AWS_PUSH_SANE_WARNING_LEVEL
15
16 struct aws_string;
17 struct aws_log_writer;
18
19 /*
20 * Log channel interface and default implementations
21 *
22 * A log channel is an abstraction for the transfer of formatted log data between a source (formatter)
23 * and a sink (writer).
24 */
25 struct aws_log_channel;
26
27 typedef int(aws_log_channel_send_fn)(struct aws_log_channel *channel, struct aws_string *output);
28 typedef void(aws_log_channel_clean_up_fn)(struct aws_log_channel *channel);
29
30 struct aws_log_channel_vtable {
31 aws_log_channel_send_fn *send;
32 aws_log_channel_clean_up_fn *clean_up;
33 };
34
35 struct aws_log_channel {
36 struct aws_log_channel_vtable *vtable;
37 struct aws_allocator *allocator;
38 struct aws_log_writer *writer;
39 void *impl;
40 };
41
42 AWS_EXTERN_C_BEGIN
43
44 /*
45 * Simple channel that results in log lines being written in the same thread they were generated in.
46 *
47 * The passed in log writer is not an ownership transfer. The log channel does not clean up the writer.
48 */
49 AWS_COMMON_API
50 int aws_log_channel_init_foreground(
51 struct aws_log_channel *channel,
52 struct aws_allocator *allocator,
53 struct aws_log_writer *writer);
54
55 /*
56 * Simple channel that sends log lines to a background thread.
57 *
58 * The passed in log writer is not an ownership transfer. The log channel does not clean up the writer.
59 */
60 AWS_COMMON_API
61 int aws_log_channel_init_background(
62 struct aws_log_channel *channel,
63 struct aws_allocator *allocator,
64 struct aws_log_writer *writer);
65
66 /*
67 * Channel cleanup function
68 */
69 AWS_COMMON_API
70 void aws_log_channel_clean_up(struct aws_log_channel *channel);
71
72 AWS_EXTERN_C_END
73 AWS_POP_SANE_WARNING_LEVEL
74
75 #endif /* AWS_COMMON_LOG_CHANNEL_H */