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

Feat/improve log #322

Merged
merged 2 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ jobs:
${{ steps.docker_meta.outputs.bake-file }}
./docker-bake.platforms.hcl
targets: rollups-node
set: rollups-node.args.ROLLUPS_NODE_VERSION=${{ steps.docker_meta.outputs.version }}
push: true
project: ${{ vars.DEPOT_PROJECT }}
workdir: build
Expand Down
4 changes: 3 additions & 1 deletion build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ ARG ROOTFS_VERSION
ARG LINUX_VERSION
ARG LINUX_KERNEL_VERSION
ARG ROM_VERSION
ARG ROLLUPS_NODE_VERSION

# Build directories.
ARG SNAPSHOT_BUILD_PATH=/build/snapshot
Expand Down Expand Up @@ -280,6 +281,7 @@ RUN cargo build --release
# First it downloads the external dependencies and then it builds the binaries.
FROM golang:${GO_VERSION}-bookworm as go-builder
ARG GO_BUILD_PATH
ARG ROLLUPS_NODE_VERSION
WORKDIR ${GO_BUILD_PATH}

# Download external dependencies.
Expand All @@ -289,7 +291,7 @@ RUN go mod download

# Build application.
COPY . .
RUN go build -ldflags "-s -w" ./cmd/cartesi-rollups-node
RUN go build -ldflags "-s -w -X 'main.buildVersion=${ROLLUPS_NODE_VERSION}'" ./cmd/cartesi-rollups-node

# STAGE: server-manager
#
Expand Down
3 changes: 3 additions & 0 deletions build/docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ target "common" {
target "rollups-node" {
inherits = ["common"]
target = "rollups-node"
args = {
ROLLUPS_NODE_VERSION = "devel"
}
}

target "rollups-node-snapshot" {
Expand Down
15 changes: 11 additions & 4 deletions cmd/cartesi-rollups-node/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ import (
"github.com/mattn/go-isatty"
)

var (
// Should be overridden during the final release build with ldflags
// to contain the actual version number
buildVersion = "devel"
)

func main() {
startTime := time.Now()

Expand All @@ -27,14 +33,15 @@ func main() {

// setup log
opts := &tint.Options{
Level: config.LogLevel,
AddSource: config.LogLevel == slog.LevelDebug,
NoColor: !config.LogPretty || !isatty.IsTerminal(os.Stdout.Fd()),
Level: config.LogLevel,
AddSource: config.LogLevel == slog.LevelDebug,
NoColor: !config.LogPretty || !isatty.IsTerminal(os.Stdout.Fd()),
TimeFormat: "2006-01-02T15:04:05.000", // RFC3339 with milliseconds and without timezone
}
handler := tint.NewHandler(os.Stdout, opts)
logger := slog.New(handler)
slog.SetDefault(logger)
slog.Info("Starting the Cartesi Rollups Node", "config", config)
slog.Info("Starting the Cartesi Rollups Node", "version", buildVersion, "config", config)

// create the node supervisor
supervisor, err := node.Setup(ctx, config)
Expand Down
Loading