@@ -17,14 +17,14 @@ describe('startup logging', () => {
1717 let tracerInfoMethod
1818
1919 before ( ( ) => {
20+ sinon . stub ( console , 'info' )
2021 sinon . stub ( console , 'warn' )
2122 delete require . cache [ require . resolve ( '../src/startup-log' ) ]
2223 const {
2324 setStartupLogConfig,
2425 setStartupLogPluginManager,
2526 setSamplingRules,
2627 startupLog,
27- logAgentError,
2828 tracerInfo,
2929 } = require ( '../src/startup-log' )
3030 tracerInfoMethod = tracerInfo
@@ -60,11 +60,13 @@ describe('startup logging', () => {
6060 ] )
6161 // Use sinon's stub instance directly to avoid type errors
6262 // eslint-disable-next-line no-console
63+ const infoStub = /** @type {sinon.SinonStub } */ ( console . info )
64+ // eslint-disable-next-line no-console
6365 const warnStub = /** @type {sinon.SinonStub } */ ( console . warn )
64- startupLog ( )
65- logAgentError ( { status : 500 , message : 'Error: fake error' } )
66- firstStderrCall = warnStub . firstCall
67- secondStderrCall = warnStub . secondCall
66+ startupLog ( { message : 'Error: fake error' } )
67+ firstStderrCall = infoStub . firstCall
68+ secondStderrCall = warnStub . firstCall
69+ infoStub . restore ( )
6870 warnStub . restore ( )
6971 } )
7072
@@ -101,7 +103,7 @@ describe('startup logging', () => {
101103 } )
102104 } )
103105
104- it ( 'logAgentError should correctly output the diagnostic message separately ' , ( ) => {
106+ it ( 'startupLog should correctly also output the diagnostic message' , ( ) => {
105107 assert . strictEqual ( secondStderrCall . args [ 0 ] , 'DATADOG TRACER DIAGNOSTIC - Agent Error: Error: fake error' )
106108 } )
107109} )
@@ -112,7 +114,7 @@ describe('data_streams_enabled', () => {
112114 } )
113115
114116 it ( 'should be true when env var is true and config is unset' , ( ) => {
115- sinon . stub ( console , 'warn ' )
117+ sinon . stub ( console , 'info ' )
116118 delete require . cache [ require . resolve ( '../src/startup-log' ) ]
117119 const {
118120 setStartupLogConfig,
@@ -125,14 +127,14 @@ describe('data_streams_enabled', () => {
125127 setStartupLogPluginManager ( { _pluginsByName : { } } )
126128 startupLog ( )
127129 /* eslint-disable-next-line no-console */
128- const warnStub = /** @type {sinon.SinonStub } */ ( console . warn )
129- const logObj = JSON . parse ( warnStub . firstCall . args [ 0 ] . replace ( 'DATADOG TRACER CONFIGURATION - ' , '' ) )
130- warnStub . restore ( )
130+ const infoStub = /** @type {sinon.SinonStub } */ ( console . info )
131+ const logObj = JSON . parse ( infoStub . firstCall . args [ 0 ] . replace ( 'DATADOG TRACER CONFIGURATION - ' , '' ) )
132+ infoStub . restore ( )
131133 assert . strictEqual ( logObj . data_streams_enabled , true )
132134 } )
133135
134136 it ( 'should be true when env var is not set and config is true' , ( ) => {
135- sinon . stub ( console , 'warn ' )
137+ sinon . stub ( console , 'info ' )
136138 delete require . cache [ require . resolve ( '../src/startup-log' ) ]
137139 const {
138140 setStartupLogConfig,
@@ -145,14 +147,14 @@ describe('data_streams_enabled', () => {
145147 setStartupLogPluginManager ( { _pluginsByName : { } } )
146148 startupLog ( )
147149 /* eslint-disable-next-line no-console */
148- const warnStub = /** @type {sinon.SinonStub } */ ( console . warn )
149- const logObj = JSON . parse ( warnStub . firstCall . args [ 0 ] . replace ( 'DATADOG TRACER CONFIGURATION - ' , '' ) )
150- warnStub . restore ( )
150+ const infoStub = /** @type {sinon.SinonStub } */ ( console . info )
151+ const logObj = JSON . parse ( infoStub . firstCall . args [ 0 ] . replace ( 'DATADOG TRACER CONFIGURATION - ' , '' ) )
152+ infoStub . restore ( )
151153 assert . strictEqual ( logObj . data_streams_enabled , true )
152154 } )
153155
154156 it ( 'should be false when env var is true but config is false' , ( ) => {
155- sinon . stub ( console , 'warn ' )
157+ sinon . stub ( console , 'info ' )
156158 delete require . cache [ require . resolve ( '../src/startup-log' ) ]
157159 const {
158160 setStartupLogConfig,
@@ -165,9 +167,9 @@ describe('data_streams_enabled', () => {
165167 setStartupLogPluginManager ( { _pluginsByName : { } } )
166168 startupLog ( )
167169 /* eslint-disable-next-line no-console */
168- const warnStub = /** @type {sinon.SinonStub } */ ( console . warn )
169- const logObj = JSON . parse ( warnStub . firstCall . args [ 0 ] . replace ( 'DATADOG TRACER CONFIGURATION - ' , '' ) )
170- warnStub . restore ( )
170+ const infoStub = /** @type {sinon.SinonStub } */ ( console . info )
171+ const logObj = JSON . parse ( infoStub . firstCall . args [ 0 ] . replace ( 'DATADOG TRACER CONFIGURATION - ' , '' ) )
172+ infoStub . restore ( )
171173 assert . strictEqual ( logObj . data_streams_enabled , false )
172174 } )
173175} )
@@ -181,7 +183,7 @@ describe('profiling_enabled', () => {
181183 [ 'auto' , true ] ,
182184 [ 'true' , true ] ,
183185 ] . forEach ( ( [ envVar , expected ] ) => {
184- sinon . stub ( console , 'warn ' )
186+ sinon . stub ( console , 'info ' )
185187 delete require . cache [ require . resolve ( '../src/startup-log' ) ]
186188 const {
187189 setStartupLogConfig,
@@ -194,9 +196,9 @@ describe('profiling_enabled', () => {
194196 setStartupLogPluginManager ( { _pluginsByName : { } } )
195197 startupLog ( )
196198 /* eslint-disable-next-line no-console */
197- const warnStub = /** @type {sinon.SinonStub } */ ( console . warn )
198- const logObj = JSON . parse ( warnStub . firstCall . args [ 0 ] . replace ( 'DATADOG TRACER CONFIGURATION - ' , '' ) )
199- warnStub . restore ( )
199+ const infoStub = /** @type {sinon.SinonStub } */ ( console . info )
200+ const logObj = JSON . parse ( infoStub . firstCall . args [ 0 ] . replace ( 'DATADOG TRACER CONFIGURATION - ' , '' ) )
201+ infoStub . restore ( )
200202 assert . strictEqual ( logObj . profiling_enabled , expected )
201203 } )
202204 } )
0 commit comments