Logging: structured slog messages throughout, and WithLogger options so callers choose the logger
Log messages are lower-case event names with their details as key/value
attributes ("error" for errors), in place of formatted strings.
Loggable package take a WithLogger option as part of their "New*" call,
defaulting to slog.Default(). Each tags its lines with its `component`.
Some debug loggers print directly rather than using slog when in
terminal logging mode.
This commit is contained in:
1 parent
0b5fde9563
commit
043e307663
49 files changed
+598
-248
No files matched your search
@@ -22,13 +22,13 @@ func NewCommand(opts *cli.Options) *cobra.Command {
|
||||
Use: "wsserve",
|
||||
Short: "Run JobSearch TCP Websocket server",
|
||||
PersistentPreRun: func(cmd *cobra.Command, args []string) {
|
||||
slog.Debug("wsserve.PersistentPreRun")
|
||||
slog.Debug("command persistent pre-run", "command", "wsserve")
|
||||
},
|
||||
PersistentPostRun: func(cmd *cobra.Command, args []string) {
|
||||
slog.Debug("wsserve.PersistentPostRun")
|
||||
slog.Debug("command persistent post-run", "command", "wsserve")
|
||||
},
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
slog.Debug("wsserve.Run")
|
||||
slog.Debug("command run", "command", "wsserve")
|
||||
|
||||
addrOverride, _ := cmd.Flags().GetString("listen")
|
||||
hostOverride, _ := cmd.Flags().GetString("host")
|
||||
@@ -74,8 +74,8 @@ func NewCommand(opts *cli.Options) *cobra.Command {
|
||||
stop()
|
||||
}()
|
||||
|
||||
hub := websocket.NewHub(conf.Server.WebSocket, slog.Default())
|
||||
svr := tcpserver.New(&conf.Server, hub, slog.Default())
|
||||
hub := websocket.NewHub(conf.Server.WebSocket)
|
||||
svr := tcpserver.New(&conf.Server, hub)
|
||||
|
||||
return svr.Run(ctx)
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user