Skip to content

Commit 414a1b9

Browse files
committed
Log client creation
1 parent bbbdbac commit 414a1b9

File tree

5 files changed

+72
-0
lines changed

5 files changed

+72
-0
lines changed

src/libmongoc/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,7 @@ set (SOURCES ${SOURCES}
539539
${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-stream-socket.c
540540
${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-structured-log.c
541541
${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-structured-log-command.c
542+
${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-structured-log-connection.c
542543
${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-topology.c
543544
${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-topology-background-monitoring.c
544545
${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-topology-description.c

src/libmongoc/src/mongoc/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ set (src_libmongoc_src_mongoc_DIST_noinst_hs
157157
mongoc-stream-gridfs-download-private.h
158158
mongoc-stream-gridfs-upload-private.h
159159
mongoc-structured-log-command-private.h
160+
mongoc-structured-log-connection-private.h
160161
mongoc-structured-log-private.h
161162
mongoc-thread-private.h
162163
mongoc-topology-description-apm-private.h

src/libmongoc/src/mongoc/mongoc-client.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
#include "mongoc-cmd-private.h"
6969
#include "mongoc-opts-private.h"
7070
#include "mongoc-structured-log-command-private.h"
71+
#include "mongoc-structured-log-connection-private.h"
7172
#endif
7273

7374

@@ -1169,6 +1170,8 @@ _mongoc_client_new_from_uri (mongoc_topology_t *topology)
11691170
}
11701171
#endif
11711172

1173+
mongoc_structured_log_connection_client_created ();
1174+
11721175
mongoc_counter_clients_active_inc ();
11731176

11741177
return client;
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright 2020 MongoDB, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#include "mongoc-prelude.h"
18+
#include "mongoc-structured-log.h"
19+
#include "mongoc-cmd-private.h"
20+
21+
#ifndef MONGOC_STRUCTRURED_LOG_CONNECTION_PRIVATE_H
22+
#define MONGOC_STRUCTRURED_LOG_CONNECTION_PRIVATE_H
23+
24+
void
25+
mongoc_structured_log_connection_client_created ();
26+
27+
#endif /* MONGOC_STRUCTURED_LOG_COMMAND_PRIVATE_H */
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright 2020 MongoDB, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
18+
#if defined(__linux__)
19+
#include <sys/syscall.h>
20+
#elif defined(_WIN32)
21+
#include <process.h>
22+
#elif defined(__FreeBSD__)
23+
#include <sys/thr.h>
24+
#else
25+
#include <unistd.h>
26+
#endif
27+
#include <time.h>
28+
29+
#include "mongoc-structured-log-private.h"
30+
31+
void
32+
mongoc_structured_log_connection_client_created ()
33+
{
34+
mongoc_structured_log (MONGOC_STRUCTURED_LOG_LEVEL_DEBUG,
35+
MONGOC_STRUCTURED_LOG_COMPONENT_CONNECTION,
36+
"Client created",
37+
NULL,
38+
NULL);
39+
40+
}

0 commit comments

Comments
 (0)