Skip to content

Commit

Permalink
refactor(log): update service ID reference and improve log message cl…
Browse files Browse the repository at this point in the history
…arity

- Update service ID reference from flags.IID() to flags.ID in logging configuration
- Modify log message to provide more context when using Consul for service discovery
  • Loading branch information
godcong committed Oct 22, 2024
1 parent bf4479f commit 4dccdaf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions cmd/helloworld/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func main() {
l := log.With(logger.NewLogger(),
"ts", log.DefaultTimestamp,
"caller", log.DefaultCaller,
"service.id", flags.IID(),
"service.id", flags.ID,
"service.name", flags.Name,
"service.version", flags.Version,
"trace.id", tracing.TraceID(),
Expand Down Expand Up @@ -85,7 +85,7 @@ func main() {

func NewApp(ctx context.Context, injector *mods.Injector) *kratos.App {
opts := []kratos.Option{
kratos.ID(flags.IID()),
kratos.ID(flags.ID),
kratos.Name(flags.Name),
kratos.Version(flags.Version),
kratos.Metadata(map[string]string{}),
Expand Down
2 changes: 1 addition & 1 deletion internal/bootstrap/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func NewRegistrar(bootstrap *configs.Bootstrap, l log.Logger) registry.Registrar
registryconsul.WithHeartbeat(cfg.HeartBeat),
registryconsul.WithHealthCheck(cfg.HealthCheck),
)
log.Infof("consul: %s", cfg.Address)
log.Infof("discovery with consul: %s", cfg.Address)
default:
panic(errors.Errorf("unknown discovery type: %s", d.Type))
}
Expand Down

0 comments on commit 4dccdaf

Please sign in to comment.