Skip to content

[Proposal] Implement lifecycle print cli option - #7658

Closed
fredericbarthelet wants to merge 3 commits into
serverless:mainfrom
fredericbarthelet:debug
Closed

fredericbarthelet wants to merge 3 commits into
serverless:mainfrom
fredericbarthelet:debug

Conversation

@fredericbarthelet

@fredericbarthelet fredericbarthelet commented May 3, 2020 •

Copy link
Copy Markdown
Contributor

What did you implement

Added a LOG_DEBUG=serverless:lifecycle cli option to every serverless commands displaying commands, events and sub-sequent hooks triggered by that command.

image

I felt the need for such a command when developing a Serverless plugin. This helped me figure out which event I should hook to in order to run the plugin code at the optimal time.

The screenshot (color choices, format) is really not pretty at the moment. I was looking for feedback towards the pros&cons of such a feature.

How can we verify it

Simply checkout on this branch and run LOG_DEBUG=serverless:lifecycle serverless deploy within any serverless project root directory.

Todos

Useful Scripts
  • npm run test:ci --> Run all validation checks on proposed changes
  • npm run lint:updated --> Lint all the updated files
  • npm run lint:fix --> Automatically fix lint problems (if possible)
  • npm run prettier-check:updated --> Check if updated files adhere to Prettier config
  • npm run prettify:updated --> Prettify all the updated files
  • Write and run all tests
  • Write documentation
  • Enable "Allow edits from maintainers" for this PR
  • Update the messages below

Is this ready for review?: YES
Is it a breaking change?: NO

@codecov-io

codecov-io commented May 4, 2020 •

Copy link
Copy Markdown

Codecov Report

Merging #7658 into master will decrease coverage by 0.29%.
The diff coverage is 23.80%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #7658      +/-   ##
==========================================
- Coverage   88.00%   87.70%   -0.30%     
==========================================
  Files         245      245              
  Lines        9202     9242      +40     
==========================================
+ Hits         8098     8106       +8     
- Misses       1104     1136      +32     
Impacted Files Coverage Δ
lib/classes/PluginManager.js 86.81% <23.80%> (-9.87%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e9726e2...eefccb7. Read the comment docs.

@medikoo medikoo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@fredericbarthelet great thanks for that proposal!

Nonetheless I believe this should be solved by improving log engine with log namespaces and levels
e.g. then you can ensure similar output by providing LOG_DEBUG=serverless:lifecycle env var

There's dedicated #1720 issue, for which PR is very welcome

@medikoo

medikoo commented Feb 25, 2022

Copy link
Copy Markdown
Contributor

@fredericbarthelet with v3 we've introduced a level based logger, and with efe1139 I've just configured basic debug logs that list triggered hooks.

It's released with v3.4.0, logs will be exposed when adding --debug=lifecycle:command:invoke:hook CLI param.

If you feel it can be improve, feel free to propose a PR :)

@medikoo medikoo closed this Feb 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants