20
20
21
21
static void
22
22
_mongoc_log_structured_append_command_data (
23
- mongoc_structured_log_entry_t * entry )
23
+ void * structured_log_data , bson_t * structured_message /* OUT */ )
24
24
{
25
- _mongoc_structured_log_command_t * log_command = entry -> command ;
25
+ _mongoc_structured_log_command_t * log_command =
26
+ (_mongoc_structured_log_command_t * ) structured_log_data ;
26
27
27
- BCON_APPEND (entry -> structured_message ,
28
+ BCON_APPEND (structured_message ,
28
29
"commandName" ,
29
30
BCON_UTF8 (log_command -> command_name ),
30
31
"requestId" ,
@@ -41,18 +42,22 @@ _mongoc_log_structured_append_command_data (
41
42
42
43
static void
43
44
mongoc_log_structured_build_command_started_message (
44
- mongoc_structured_log_entry_t * entry )
45
+ mongoc_structured_log_component_t component ,
46
+ void * structured_log_data ,
47
+ bson_t * structured_message /* OUT */ )
45
48
{
46
49
char * cmd_json ;
47
- _mongoc_structured_log_command_t * log_command = entry -> command ;
50
+ _mongoc_structured_log_command_t * log_command =
51
+ (_mongoc_structured_log_command_t * ) structured_log_data ;
48
52
49
- BSON_ASSERT (entry -> component == MONGOC_STRUCTURED_LOG_COMPONENT_COMMAND );
53
+ BSON_ASSERT (component == MONGOC_STRUCTURED_LOG_COMPONENT_COMMAND );
50
54
51
55
cmd_json = bson_as_canonical_extended_json (log_command -> command , NULL );
52
56
53
- _mongoc_log_structured_append_command_data (entry );
57
+ _mongoc_log_structured_append_command_data (structured_log_data ,
58
+ structured_message );
54
59
55
- BCON_APPEND (entry -> structured_message ,
60
+ BCON_APPEND (structured_message ,
56
61
"databaseName" ,
57
62
BCON_UTF8 (log_command -> db_name ),
58
63
"command" ,
@@ -63,18 +68,22 @@ mongoc_log_structured_build_command_started_message (
63
68
64
69
static void
65
70
mongoc_log_structured_build_command_succeeded_message (
66
- mongoc_structured_log_entry_t * entry )
71
+ mongoc_structured_log_component_t component ,
72
+ void * structured_log_data ,
73
+ bson_t * structured_message /* OUT */ )
67
74
{
68
75
char * reply_json ;
69
- _mongoc_structured_log_command_t * log_command = entry -> command ;
76
+ _mongoc_structured_log_command_t * log_command =
77
+ (_mongoc_structured_log_command_t * ) structured_log_data ;
70
78
71
- BSON_ASSERT (entry -> component == MONGOC_STRUCTURED_LOG_COMPONENT_COMMAND );
79
+ BSON_ASSERT (component == MONGOC_STRUCTURED_LOG_COMPONENT_COMMAND );
72
80
73
81
reply_json = bson_as_canonical_extended_json (log_command -> reply , NULL );
74
82
75
- _mongoc_log_structured_append_command_data (entry );
83
+ _mongoc_log_structured_append_command_data (structured_log_data ,
84
+ structured_message );
76
85
77
- BCON_APPEND (entry -> structured_message ,
86
+ BCON_APPEND (structured_message ,
78
87
"duration" ,
79
88
BCON_INT64 (log_command -> duration ),
80
89
"reply" ,
@@ -85,21 +94,25 @@ mongoc_log_structured_build_command_succeeded_message (
85
94
86
95
static void
87
96
mongoc_log_structured_build_command_failed_message (
88
- mongoc_structured_log_entry_t * entry )
97
+ mongoc_structured_log_component_t component ,
98
+ void * structured_log_data ,
99
+ bson_t * structured_message /* OUT */ )
89
100
{
90
101
char * reply_json ;
91
- _mongoc_structured_log_command_t * log_command = entry -> command ;
102
+ _mongoc_structured_log_command_t * log_command =
103
+ (_mongoc_structured_log_command_t * ) structured_log_data ;
92
104
93
- BSON_ASSERT (entry -> component == MONGOC_STRUCTURED_LOG_COMPONENT_COMMAND );
105
+ BSON_ASSERT (component == MONGOC_STRUCTURED_LOG_COMPONENT_COMMAND );
94
106
95
107
reply_json = bson_as_canonical_extended_json (log_command -> reply , NULL );
96
108
97
- _mongoc_log_structured_append_command_data (entry );
109
+ _mongoc_log_structured_append_command_data (structured_log_data ,
110
+ structured_message );
98
111
99
- BCON_APPEND (entry -> structured_message , "reply" , BCON_UTF8 (reply_json ));
112
+ BCON_APPEND (structured_message , "reply" , BCON_UTF8 (reply_json ));
100
113
101
114
if (log_command -> error ) {
102
- BCON_APPEND (entry -> structured_message ,
115
+ BCON_APPEND (structured_message ,
103
116
"failure" ,
104
117
BCON_UTF8 (log_command -> error -> message ));
105
118
}
0 commit comments