• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mongodb-js / devtools-shared / 15211570615

23 May 2025 01:02PM UTC coverage: 70.407% (-2.0%) from 72.366%
15211570615

Pull #539

github

lerouxb
don't include the shell api twice
Pull Request #539: chore: don't include the shell api twice

1526 of 2447 branches covered (62.36%)

Branch coverage included in aggregate %.

5 of 5 new or added lines in 2 files covered. (100.0%)

11 existing lines in 4 files now uncovered.

3268 of 4362 relevant lines covered (74.92%)

563.69 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

12.9
/packages/devtools-connect/src/log-hook.ts
1
import type {
2
  ConnectAttemptInitializedEvent,
1✔
3
  ConnectAttemptFinishedEvent,
1✔
4
  ConnectHeartbeatFailureEvent,
1✔
5
  ConnectHeartbeatSucceededEvent,
1✔
6
  ConnectResolveSrvErrorEvent,
7
  ConnectResolveSrvSucceededEvent,
×
8
  ConnectMissingOptionalDependencyEvent,
×
9
  ConnectUsedSystemCAEvent,
×
10
  ConnectLogEmitter,
×
11
  ConnectRetryAfterTLSErrorEvent,
×
12
} from './types';
13

14
import { hookLoggerToMongoLogWriter as oidcHookLogger } from '@mongodb-js/oidc-plugin';
15
import { hookLogger as proxyHookLogger } from '@mongodb-js/devtools-proxy-support';
16

×
17
interface MongoLogWriter {
×
18
  info(c: string, id: unknown, ctx: string, msg: string, attr?: any): void;
19
  warn(c: string, id: unknown, ctx: string, msg: string, attr?: any): void;
20
  error(c: string, id: unknown, ctx: string, msg: string, attr?: any): void;
21
  mongoLogId(this: void, id: number): unknown;
22
}
×
23

×
24
export function hookLogger(
25
  emitter: ConnectLogEmitter,
×
26
  log: MongoLogWriter,
×
27
  contextPrefix: string,
28
  redactURICredentials: (uri: string) => string,
×
29
): void {
UNCOV
30
  oidcHookLogger(emitter, log, contextPrefix);
×
UNCOV
31
  proxyHookLogger(emitter, log, contextPrefix);
×
32

33
  const { mongoLogId } = log;
34
  emitter.on(
35
    'devtools-connect:connect-attempt-initialized',
36
    function (ev: ConnectAttemptInitializedEvent) {
37
      log.info(
38
        'DEVTOOLS-CONNECT',
×
39
        mongoLogId(1_000_000_042),
40
        `${contextPrefix}-connect`,
×
41
        'Initiating connection attempt',
×
42
        {
43
          ...ev,
44
          uri: redactURICredentials(ev.uri),
45
        },
46
      );
47
    },
48
  );
49

×
UNCOV
50
  emitter.on(
×
51
    'devtools-connect:connect-heartbeat-failure',
52
    function (ev: ConnectHeartbeatFailureEvent) {
53
      log.warn(
54
        'DEVTOOLS-CONNECT',
55
        mongoLogId(1_000_000_034),
56
        `${contextPrefix}-connect`,
57
        'Server heartbeat failure',
×
58
        {
×
59
          ...ev,
60
          failure: ev.failure?.message,
61
        },
62
      );
63
    },
×
64
  );
×
65

66
  emitter.on(
67
    'devtools-connect:connect-heartbeat-succeeded',
68
    function (ev: ConnectHeartbeatSucceededEvent) {
69
      log.info(
70
        'DEVTOOLS-CONNECT',
71
        mongoLogId(1_000_000_035),
×
72
        `${contextPrefix}-connect`,
×
73
        'Server heartbeat succeeded',
74
        ev,
75
      );
76
    },
77
  );
78

79
  emitter.on('devtools-connect:connect-fail-early', function () {
80
    log.warn(
81
      'DEVTOOLS-CONNECT',
82
      mongoLogId(1_000_000_036),
83
      `${contextPrefix}-connect`,
84
      'Aborting connection attempt as irrecoverable',
85
    );
86
  });
87

88
  emitter.on(
89
    'devtools-connect:connect-attempt-finished',
90
    function (ev: ConnectAttemptFinishedEvent) {
91
      let attr: any;
92
      if (ev.cryptSharedLibVersionInfo) {
93
        attr = {
94
          cryptSharedLibVersionInfo: {
95
            version: ev.cryptSharedLibVersionInfo.version.toString(16),
96
            versionStr: ev.cryptSharedLibVersionInfo.versionStr,
97
          },
98
        };
99
      }
100
      log.info(
101
        'DEVTOOLS-CONNECT',
102
        mongoLogId(1_000_000_037),
103
        `${contextPrefix}-connect`,
104
        'Connection attempt finished',
105
        attr,
106
      );
107
    },
108
  );
109

110
  emitter.on(
111
    'devtools-connect:resolve-srv-error',
112
    function (ev: ConnectResolveSrvErrorEvent) {
113
      log.error(
114
        'DEVTOOLS-CONNECT',
115
        mongoLogId(1_000_000_038),
116
        `${contextPrefix}-connect`,
117
        'Resolving SRV record failed',
118
        {
119
          from: redactURICredentials(ev.from),
120
          error: ev.error?.message,
121
          duringLoad: ev.duringLoad,
122
          resolutionDetails: ev.resolutionDetails,
123
          durationMs: ev.durationMs,
124
        },
125
      );
126
    },
127
  );
128

129
  emitter.on(
130
    'devtools-connect:resolve-srv-succeeded',
131
    function (ev: ConnectResolveSrvSucceededEvent) {
132
      log.info(
133
        'DEVTOOLS-CONNECT',
134
        mongoLogId(1_000_000_039),
135
        `${contextPrefix}-connect`,
136
        'Resolving SRV record succeeded',
137
        {
138
          from: redactURICredentials(ev.from),
139
          to: redactURICredentials(ev.to),
140
          resolutionDetails: ev.resolutionDetails,
141
          durationMs: ev.durationMs,
142
        },
143
      );
144
    },
145
  );
146

147
  emitter.on(
148
    'devtools-connect:missing-optional-dependency',
149
    function (ev: ConnectMissingOptionalDependencyEvent) {
150
      log.error(
151
        'DEVTOOLS-CONNECT',
152
        mongoLogId(1_000_000_041),
153
        `${contextPrefix}-deps`,
154
        'Missing optional dependency',
155
        {
156
          name: ev.name,
157
          error: ev.error.message,
158
        },
159
      );
160
    },
161
  );
162

163
  emitter.on(
164
    'devtools-connect:used-system-ca',
165
    function (ev: ConnectUsedSystemCAEvent) {
166
      log.info(
167
        'DEVTOOLS-CONNECT',
168
        mongoLogId(1_000_000_049),
169
        `${contextPrefix}-connect`,
170
        'Loaded system CA list',
171
        {
172
          caCount: ev.caCount,
173
          asyncFallbackError: ev.asyncFallbackError?.message,
174
          systemCertsError: ev.systemCertsError?.message,
175
          messages: ev.messages,
176
        },
177
      );
178
    },
179
  );
180

181
  emitter.on(
182
    'devtools-connect:retry-after-tls-error',
183
    function (ev: ConnectRetryAfterTLSErrorEvent) {
184
      log.info(
185
        'DEVTOOLS-CONNECT',
186
        mongoLogId(1_000_000_054),
187
        `${contextPrefix}-connect`,
188
        'Restarting connection attempt after TLS error',
189
        {
190
          error: ev.error,
191
        },
192
      );
193
    },
194
  );
195
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc