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

anvil logs to a tmp file #42

Merged
merged 2 commits into from
Jul 11, 2024
Merged

anvil logs to a tmp file #42

merged 2 commits into from
Jul 11, 2024

Conversation

hamdiallam
Copy link
Contributor

@hamdiallam hamdiallam commented Jul 10, 2024

for now we rely on inspecting the anvil logs to grab the port when bound to 0.

Rather than use the --silent flag, dump anvil log to temporary files such that they are inspectable for the user

@hamdiallam hamdiallam requested a review from a team as a code owner July 10, 2024 18:31
for _, l2OpSim := range s.l2OpSims {
fmt.Fprintf(&b, " Chain ID: %d RPC: %s\n", l2OpSim.ChainId(), l2OpSim.Endpoint())
for id, l2OpSim := range s.l2OpSims {
fmt.Fprintf(&b, " Chain ID: %d RPC: %s LogPath: %s\n", l2OpSim.ChainId(), l2OpSim.Endpoint(), s.l2Anvils[id].LogPath())
Copy link
Contributor

Choose a reason for hiding this comment

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

i doubt this will happen the way everything is setup but i'm wondering if we should add a nil check for this specifically s.l2Anvils[id].LogPath()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmm given the setup there's no good way to gracefully recover from a programming mistake here so better to simply panic

we can add a unit test though that asserts the key is present in both maps when setup. That should cover this case

@@ -90,7 +92,12 @@ func (a *Anvil) Start(ctx context.Context) error {
anvilPortCh := make(chan uint64)

// Handle stdout/stderr
// - TODO: Figure out best way to dump into logger. Some hex isn't showing appropriately
logFile, err := os.CreateTemp("", fmt.Sprintf("anvil-chain-%d-", a.cfg.ChainId))
Copy link
Contributor

Choose a reason for hiding this comment

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

extra - at the end?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah this was a mistake, will remove

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah wait no actually the extra - is there becase CreateTemp appends a random string of characters at the end for name collision

@hamdiallam hamdiallam merged commit 4093e98 into main Jul 11, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants