-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch to json logger in orchestrator and daemon #1831
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
5cdd58e
Switch to json logger in orchestrator and daemon
NicolasMahe bc2fe42
improve logger creation in daemon cli
NicolasMahe e8fb767
Merge branch 'dev' into feature/improve-logs
077b53c
force json logs for daemon
antho1404 b17a3f9
custom lcd server with json log
antho1404 7f9d0a4
Merge pull request #1832 from mesg-foundation/feature/improve-logs-2
940fcc0
move lcd serve command to a dedicated file
NicolasMahe 28a2f36
cleanup go mod dep and add link to original function
NicolasMahe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"net" | ||
"os" | ||
"time" | ||
|
||
"github.com/cosmos/cosmos-sdk/client" | ||
"github.com/cosmos/cosmos-sdk/client/context" | ||
"github.com/cosmos/cosmos-sdk/client/flags" | ||
"github.com/cosmos/cosmos-sdk/codec" | ||
"github.com/cosmos/cosmos-sdk/server" | ||
authrest "github.com/cosmos/cosmos-sdk/x/auth/client/rest" | ||
"github.com/gorilla/mux" | ||
"github.com/mesg-foundation/engine/app" | ||
"github.com/mesg-foundation/engine/cosmos" | ||
"github.com/spf13/cobra" | ||
"github.com/spf13/viper" | ||
"github.com/tendermint/tendermint/libs/log" | ||
rpcserver "github.com/tendermint/tendermint/rpc/lib/server" | ||
) | ||
|
||
// ServeCommand creates and starts the LCD server | ||
// adapted version of function from https://github.com/cosmos/cosmos-sdk/blob/v0.38.3/client/lcd/root.go#L74-L100 | ||
func ServeCommand(cdc *codec.Codec) *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "rest-server", | ||
Short: "Start LCD (light-client daemon), a local REST server", | ||
RunE: func(cmd *cobra.Command, args []string) (err error) { | ||
// new rest server | ||
r := mux.NewRouter() | ||
cliCtx := context.NewCLIContext().WithCodec(cdc) | ||
logger := log.NewTMJSONLogger(log.NewSyncWriter(os.Stdout)).With("module", "rest-server") | ||
|
||
// register routes | ||
client.RegisterRoutes(cliCtx, r) | ||
authrest.RegisterTxRoutes(cliCtx, r) | ||
app.ModuleBasics.RegisterRESTRoutes(cliCtx, r) | ||
cosmos.RegisterSimulateRoute(cliCtx, r) | ||
|
||
// start | ||
var listener net.Listener | ||
server.TrapSignal(func() { | ||
err := listener.Close() | ||
logger.Error("error closing listener", "err", err) | ||
}) | ||
|
||
cfg := rpcserver.DefaultConfig() | ||
cfg.MaxOpenConnections = viper.GetInt(flags.FlagMaxOpenConnections) | ||
cfg.ReadTimeout = time.Duration(uint(viper.GetInt(flags.FlagRPCReadTimeout))) * time.Second | ||
cfg.WriteTimeout = time.Duration(uint(viper.GetInt(flags.FlagRPCWriteTimeout))) * time.Second | ||
|
||
listener, err = rpcserver.Listen(viper.GetString(flags.FlagListenAddr), cfg) | ||
if err != nil { | ||
return | ||
} | ||
logger.Info( | ||
fmt.Sprintf( | ||
"Starting application REST service (chain-id: %q)...", | ||
viper.GetString(flags.FlagChainID), | ||
), | ||
) | ||
|
||
return rpcserver.StartHTTPServer(listener, r, logger, cfg) | ||
}, | ||
} | ||
|
||
return flags.RegisterRestServerFlags(cmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wraped the function
server.PersistentPreRunEFn
because it does some stuff using private function and it replaces thecontext.Logger
inside the function (even if the logger is already initialized..)