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

Write logs to filesystem #522

Merged
merged 5 commits into from
Nov 28, 2023
Merged

Write logs to filesystem #522

merged 5 commits into from
Nov 28, 2023

Conversation

sdankel
Copy link
Member

@sdankel sdankel commented Nov 22, 2023

Closes #519

This writes logs to ~/.fuelup/log rolling over every hour. For example ~/.fuelup/log/fuelup.log.2023-11-22-00

Since tracing is used for showing output to the user as well, I added a filter so thatdebug logs will only be logged to the filesystem, not shown to the user.

The PR also includes:

  • Cleans up existing logs: the output shown to the user is a combination of tracing and plain writelns. In order for the log file to capture everything the user is shown, we should output everything through tracing macros.
  • Adds useful debug logs about the environment and the command that was called. It doesn't log the full PATH, because that could contain sensitive information, rather it logs whether or not the .fuelup directory is part of the path.

Example of the current log output after fuelup show:

User sees

$ fuelup show
Default host: x86_64-apple-darwin
fuelup home: /Users/sophiedankel/.fuelup

installed toolchains
--------------------
beta-3-x86_64-apple-darwin
beta-4-aarch64-apple-darwin (default)
latest-aarch64-apple-darwin

active toolchain
-----------------
beta-4-aarch64-apple-darwin (default)
  forc : 0.46.1
    - forc-client
      - forc-deploy - not found
      - forc-run - not found
    - forc-doc - not found
    - forc-explore - not found
    - forc-fmt - not found
    - forc-index - not found
    - forc-lsp - not found
    - forc-tx - not found
    - forc-wallet - not found
  fuel-core : 0.20.5
  fuel-core-keygen : Error getting version string
  fuel-indexer : 0.23.0

fuels versions
---------------
forc : 0.45

Logged to file

$ cat ~/.fuelup/log/fuelup.log.2023-11-27-02 
2023-11-27T02:51:30.172198Z DEBUG Command: fuelup show
2023-11-27T02:51:30.172325Z DEBUG PATH includes /Users/sophiedankel/.fuelup/bin
2023-11-27T02:51:30.172330Z DEBUG FUELUP_HOME is not set
2023-11-27T02:51:30.173654Z  INFO Default host: x86_64-apple-darwin
2023-11-27T02:51:30.173717Z  INFO fuelup home: /Users/sophiedankel/.fuelup
2023-11-27T02:51:30.173722Z  INFO 
2023-11-27T02:51:30.173725Z  INFO installed toolchains
2023-11-27T02:51:30.173728Z  INFO --------------------
2023-11-27T02:51:30.177851Z  INFO beta-3-x86_64-apple-darwin
2023-11-27T02:51:30.177868Z  INFO beta-4-aarch64-apple-darwin (default)
2023-11-27T02:51:30.177872Z  INFO latest-aarch64-apple-darwin
2023-11-27T02:51:30.177877Z  INFO 
2023-11-27T02:51:30.177882Z  INFO active toolchain
2023-11-27T02:51:30.177884Z  INFO ----------------
2023-11-27T02:51:30.177888Z  INFO beta-4-aarch64-apple-darwin (default)
2023-11-27T02:51:30.192053Z  INFO   forc : 0.46.1
2023-11-27T02:51:30.192401Z  INFO     - forc-client
2023-11-27T02:51:30.192606Z  INFO       - forc-deploy : not found
2023-11-27T02:51:30.192757Z  INFO       - forc-run : not found
2023-11-27T02:51:30.192848Z  INFO     - forc-doc : not found
2023-11-27T02:51:30.193018Z  INFO     - forc-explore : not found
2023-11-27T02:51:30.193096Z  INFO     - forc-fmt : not found
2023-11-27T02:51:30.193174Z  INFO     - forc-index : not found
2023-11-27T02:51:30.193256Z  INFO     - forc-lsp : not found
2023-11-27T02:51:30.193331Z  INFO     - forc-tx : not found
2023-11-27T02:51:30.193423Z  INFO     - forc-wallet : not found
2023-11-27T02:51:30.217404Z  INFO   fuel-core : 0.20.5
2023-11-27T02:51:30.221223Z  INFO   fuel-core-keygen : Error getting version string
2023-11-27T02:51:30.247717Z  INFO   fuel-indexer : 0.23.0
2023-11-27T02:51:30.248265Z  INFO 
2023-11-27T02:51:30.248275Z  INFO fuels versions
2023-11-27T02:51:30.248277Z  INFO --------------
2023-11-27T02:51:30.248281Z  INFO forc : 0.45

@sdankel sdankel requested review from kayagokalp and a team November 22, 2023 00:53
@JoshuaBatty
Copy link
Member

Nice this will be helpful. Just wondering if we should provide a bit more information in the log about which component wasn't found?

@kayagokalp
Copy link
Member

Thanks for tackling this! Wonder if we should also log things like $PATH ?

@JoshuaBatty
Copy link
Member

just looking at the logs and this part confused me a bit

2023-11-27T02:51:30.172330Z DEBUG FUELUP_HOME is not set
...
2023-11-27T02:51:30.173717Z  INFO fuelup home: /Users/sophiedankel/.fuelup

is FUELUP_HOME and fuelup home the same thing?

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.

Add a logging system for better reproducing bugs
5 participants