Skip to content
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

Dev Tools: Integrate Logfile Navigator (lnav) #5000

Merged
merged 5 commits into from
Mar 24, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions daemon/algod/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,17 +142,17 @@ func (s *Server) Initialize(cfg config.Local, phonebookAddresses []string, genes

// if we have the telemetry enabled, we want to use it's sessionid as part of the
// collected metrics decorations.
fmt.Fprintln(logWriter, "++++++++++++++++++++++++++++++++++++++++")
fmt.Fprintln(logWriter, "Logging Starting")
fmt.Println("++++++++++++++++++++++++++++++++++++++++")
fmt.Println("Logging Starting")
if s.log.GetTelemetryUploadingEnabled() {
// May or may not be logging to node.log
fmt.Fprintf(logWriter, "Telemetry Enabled: %s\n", s.log.GetTelemetryGUID())
fmt.Fprintf(logWriter, "Session: %s\n", s.log.GetTelemetrySession())
fmt.Printf("Telemetry Enabled: %s\n", s.log.GetTelemetryGUID())
fmt.Printf("Session: %s\n", s.log.GetTelemetrySession())
Aharonee marked this conversation as resolved.
Show resolved Hide resolved
} else {
// May or may not be logging to node.log
fmt.Fprintln(logWriter, "Telemetry Disabled")
fmt.Println("Telemetry Disabled")
}
fmt.Fprintln(logWriter, "++++++++++++++++++++++++++++++++++++++++")
fmt.Println("++++++++++++++++++++++++++++++++++++++++")

metricLabels := map[string]string{}
if s.log.GetTelemetryEnabled() {
Expand Down
49 changes: 49 additions & 0 deletions scripts/algorand_node_log.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"algorand_node_log" : {
"title" : "Algornad Node Log Format",
bbroder-algo marked this conversation as resolved.
Show resolved Hide resolved
"description" : "Log format for logrus, used by go-algorand.",
"url" : "https://github.com/sirupsen/logrus",
"file-pattern": "node.log",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

node archive is missing

Copy link
Contributor Author

@Aharonee Aharonee Jan 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

file-pattern is used to avoid potential conflicts when lnav chooses the file format to use.
I've replaced it with sample which defines some log line samples and uses them for conflict resolution instead (seems like this is the more common approach).

"level-field" : "level",
"timestamp-field" : "time",
"json": true,
"body-field": "msg",
"line-format" : [
{ "field" : "time", "timestamp-format": "%b %d %H:%M:%S" },
" ",
{ "field" : "level", "text-transform": "uppercase", "min-width": 4, "max-width": 4, "overflow": "truncate"},
" ",
"[", { "field": "file" }, ":", {"field": "line"}, "]",
" ",
{ "field": "Context" },
" ",
{ "field" : "msg" },
" [", { "field": "function" }, "]"
],
"hide-extra": true,
"level" : {
"info" : "info",
"error" : "error",
"warning" : "warning",
"debug" : "debug"
},
"value": {
"file": {
"kind": "string",
"identifier": true
},
"line": {
"kind": "integer",
"foreign-key": true
},
"function": {
"kind": "string",
"identifier": true
},
"Context": {
"kind": "string",
"identifier": true
}
}
}
}
2 changes: 2 additions & 0 deletions scripts/configure_dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ elif [ "${OS}" = "darwin" ]; then
install_or_upgrade autoconf
install_or_upgrade automake
install_or_upgrade python3
install_or_upgrade lnav
lnav -i "$SCRIPTPATH/algorand_node_log.json"
fi
elif [ "${OS}" = "windows" ]; then
if ! $msys2 pacman -S --disable-download-timeout --noconfirm git automake autoconf m4 libtool make mingw-w64-x86_64-gcc mingw-w64-x86_64-boost mingw-w64-x86_64-python mingw-w64-x86_64-jq unzip procps; then
Expand Down