| 1 |
|
| 2 |
#ifndef AWS_COMMON_LOG_FORMATTER_H |
| 3 |
#define AWS_COMMON_LOG_FORMATTER_H |
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
#include <aws/common/common.h> |
| 11 |
|
| 12 |
#include <aws/common/date_time.h> |
| 13 |
#include <aws/common/logging.h> |
| 14 |
|
| 15 |
#include <stdarg.h> |
| 16 |
#include <stdio.h> |
| 17 |
|
| 18 |
AWS_PUSH_SANE_WARNING_LEVEL |
| 19 |
|
| 20 |
struct aws_allocator; |
| 21 |
struct aws_string; |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
struct aws_log_formatter; |
| 30 |
|
| 31 |
typedef int(aws_log_formatter_format_fn)( |
| 32 |
struct aws_log_formatter *formatter, |
| 33 |
struct aws_string **formatted_output, |
| 34 |
enum aws_log_level level, |
| 35 |
aws_log_subject_t subject, |
| 36 |
const char *format, |
| 37 |
va_list args); |
| 38 |
|
| 39 |
typedef void(aws_log_formatter_clean_up_fn)(struct aws_log_formatter *logger); |
| 40 |
|
| 41 |
struct aws_log_formatter_vtable { |
| 42 |
aws_log_formatter_format_fn *format; |
| 43 |
aws_log_formatter_clean_up_fn *clean_up; |
| 44 |
}; |
| 45 |
|
| 46 |
struct aws_log_formatter { |
| 47 |
struct aws_log_formatter_vtable *vtable; |
| 48 |
struct aws_allocator *allocator; |
| 49 |
void *impl; |
| 50 |
}; |
| 51 |
|
| 52 |
struct aws_log_formatter_standard_options { |
| 53 |
enum aws_date_format date_format; |
| 54 |
}; |
| 55 |
|
| 56 |
struct aws_logging_standard_formatting_data { |
| 57 |
char *log_line_buffer; |
| 58 |
size_t total_length; |
| 59 |
enum aws_log_level level; |
| 60 |
const char *subject_name; |
| 61 |
const char *format; |
| 62 |
enum aws_date_format date_format; |
| 63 |
struct aws_allocator *allocator; |
| 64 |
|
| 65 |
size_t amount_written; |
| 66 |
}; |
| 67 |
|
| 68 |
AWS_EXTERN_C_BEGIN |
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
AWS_COMMON_API |
| 76 |
int aws_log_formatter_init_default( |
| 77 |
struct aws_log_formatter *formatter, |
| 78 |
struct aws_allocator *allocator, |
| 79 |
struct aws_log_formatter_standard_options *options); |
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
AWS_COMMON_API |
| 86 |
void aws_log_formatter_clean_up(struct aws_log_formatter *formatter); |
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
AWS_COMMON_API |
| 93 |
int aws_format_standard_log_line(struct aws_logging_standard_formatting_data *formatting_data, va_list args); |
| 94 |
|
| 95 |
AWS_EXTERN_C_END |
| 96 |
AWS_POP_SANE_WARNING_LEVEL |
| 97 |
|
| 98 |
#endif |