@@ -183,7 +183,7 @@ func NewEmulatorServer(logger *zerolog.Logger, conf *Config) (*EmulatorServer, e
183183 // Derive chain ID for the emulator setup.
184184 resolvedChainID := conf .ChainID
185185 if conf .ForkHost != "" && conf .ChainID == "" {
186- parsed , err := DetectRemoteChainID (conf .ForkHost )
186+ parsed , err := DetectRemoteChainID (logger , conf .ForkHost )
187187 if err != nil {
188188 logger .Error ().Err (err ).Str ("forkHost" , conf .ForkHost ).Msg ("❗ Failed to detect remote chain ID" )
189189 return nil , fmt .Errorf ("failed to detect remote chain ID from %s: %w" , conf .ForkHost , err )
@@ -279,35 +279,35 @@ func NewEmulatorServer(logger *zerolog.Logger, conf *Config) (*EmulatorServer, e
279279}
280280
281281// detectRemoteChainID connects to the remote access node and fetches network parameters to obtain the chain ID.
282- func DetectRemoteChainID (url string ) (flowgo.ChainID , error ) {
283- _ , _ = fmt . Fprintf ( os . Stdout , "Detecting chain ID for: %s \n " , url )
282+ func DetectRemoteChainID (logger * zerolog. Logger , url string ) (flowgo.ChainID , error ) {
283+ logger . Info (). Str ( "url" , url ). Msg ( "Detecting chain ID" )
284284
285285 // Expect raw host:port
286286 conn , err := grpc .NewClient (
287287 url ,
288288 grpc .WithTransportCredentials (insecure .NewCredentials ()),
289- utils .DefaultGRPCRetryInterceptor ( ),
289+ utils .DefaultGRPCRetryInterceptorWithLogger ( logger ),
290290 )
291291 if err != nil {
292- _ , _ = fmt . Fprintf ( os . Stderr , "❌ Failed to connect to %s: %v \n " , url , err )
292+ logger . Error (). Err ( err ). Str ( "url" , url ). Msg ( " Failed to create gRPC client" )
293293 return "" , err
294294 }
295295 defer func () { _ = conn .Close () }()
296296
297297 client := flowaccess .NewAccessAPIClient (conn )
298298 resp , err := client .GetNetworkParameters (context .Background (), & flowaccess.GetNetworkParametersRequest {})
299299 if err != nil {
300- _ , _ = fmt . Fprintf ( os . Stderr , "❌ GetNetworkParameters failed for %s: %v \n " , url , err )
300+ logger . Error (). Err ( err ). Str ( "url" , url ). Msg ( " GetNetworkParameters failed" )
301301 return "" , err
302302 }
303303
304304 if resp == nil {
305- _ , _ = fmt . Fprintf ( os . Stderr , "❌ GetNetworkParameters returned nil response for: %s \n " , url )
305+ logger . Error (). Str ( "url" , url ). Msg ( " GetNetworkParameters returned nil response" )
306306 return "" , fmt .Errorf ("GetNetworkParameters returned nil response" )
307307 }
308308
309309 chainID := flowgo .ChainID (resp .ChainId )
310- _ , _ = fmt . Fprintf ( os . Stdout , "✅ Detected chain ID: %s from %s \n " , string (chainID ), url )
310+ logger . Info (). Str ( "url" , url ). Str ( "chainId " , string (chainID )). Msg ( "Successfully detected chain ID" )
311311
312312 return chainID , nil
313313}
0 commit comments