You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now serverless always output current step during deploy. It's always the same, so I'm not sure if it make sense to output that every time.
My proposition is to use log levels and output logs only if user ask for them.
serverless deploy --region us-west-2 --log-level info
Possible log levels:
info - same as current default
debug - same as current with SLS_DEBUG flag on
error - only errors
Proposed solution
(Added in later turn by maintainers)
Ideally if all logging in context of a Framework is pursued through log library which apart of supporting log levels also supports namespaces (debug style) and is already used in tests and some dependencies.
What's important, this will also open the door for pure programmatic use of core without producing CLI logs noise, as proposed log library does not write logs but just emit events, and it's a CLI handler through which a real CLI logs writer (log-node) is initialized which listens for events as emitted by log
When migrating Framework to new logger, ensure to also deprecate --verbose params in all commands, as output should be purely controlled via LOG_LEVEL and LOG_DEBUG environment variables
Reacted by Mariusz Nowak, Stefan Horning, Peter Reshetin, thetumper, Stephen Bawks and arashilmg
Yep agreed. I think these prints are just temporary. We'll probably just have a spinner or progress bar. We're also thinking about debugging logs with more info that runs whenever you have SLS_DEBUG (or just DEBUG?) set. But totally agreed, the user should have control over the log level.
env vars has the advantage of always staying in debug mode (as long as you have this env var set) during development... In v0 we had --debug option, which just added the env var for the user. Hmmm maybe we should bring that back.
I added a debug view into the system that allows me place the whole framework into node-inspector and do interactive debugging while things are executing. You are able to set breakpoints etc. as well as see the debug output as if the (--debug option) had been selected. You start the system with alternate command: sls-debug. I will post it as a pull request for review.
I like the --log-level idea. At the moment I don't think we should put too much time into it ourselves, but it would be great as a contribution from the community if somebody wants to pick it up.
Following @medikoo recommendations, I updated my PR #7658 in order to use LOG_DEBUG namespace value to output command/hook lifecycle in the terminal for the requested serverless command.
The way I implemented it is very simple, juste checking for this env var value before writing lifecycle to console.
All PRs linked to this conversation stalled, and I imagine my simple solution to be too simple for the task at hand here. However, I would be happy to help implementing lifecycle debut print feature following your recommendations, if any :) Any feedback on my PR of what I should develop for this to be integrated ?
@fredericbarthelet This PR is about improving how we handle logs in general (by introducing real log levels and namespaces).
Lifecycle logging could be first one to get advantage of the feature. However first we'd need at least minimal configuration of a new logger.
Technically just initializing log-node writter in bin/serverless.js will do most of the job. However it'll be good to fine tune the writer, so logs output style resemble one we have now (we should not introduce a dramatic change of how logs look).
Having that logs for lifecycle engine could be configure just with:
Note that also debug branch, has hardcoded lifecycle logs - it serves as a temporary workaround, until we have them naturally provided with new log engine
@medikoo, I implemented the feature using log and log-node.
It works as expected and produces outputs on the terminal based on LOG_DEBUG and LOG_LEVEL env vars. However, as you pointed out, the writer output styles is far from existing Serverless logs style. I did not find any option other than defaultNamespace within the writter to be able to fine tune it.
While searching for such a way to customize log outputs, I found this neat cli logger called signale which allows output style configuration via JSON out of the box. It misses the automatic use of both previously mentioned env vars, but this could be implemented directly within the logger configuration. WDYT of using such logging library ? Should I stick with log-node writter and make a PR on it as well to allow style configuration options ?
However, as you pointed out, the writer output styles is far from existing Serverless logs style. I did not find any option other than defaultNamespace within the writter to be able to fine tune it.
Yes, I believe we need to prepare our own custom writer (e.g. log-serverless) that derives from log-node and tweaks needed parts. I'll try to prepare one soon, and then we'd be able to jump on it.
I'll post it here once it's ready
Reacted by Frédéric Barthelet, David Halewood and Peter Reshetin
Activity
eahefnawy commentedon Aug 1, 2016
Yep agreed. I think these prints are just temporary. We'll probably just have a spinner or progress bar. We're also thinking about debugging logs with more info that runs whenever you have
SLS_DEBUG(or justDEBUG?) set. But totally agreed, the user should have control over the log level.mthenw commentedon Aug 1, 2016
Yeah, but why env var for that and not CLI param? I guess most of the tools use CLI param for that.
eahefnawy commentedon Aug 1, 2016
env vars has the advantage of always staying in debug mode (as long as you have this env var set) during development... In v0 we had
--debugoption, which just added the env var for the user. Hmmm maybe we should bring that back.Bilal-S commentedon Aug 2, 2016
I added a debug view into the system that allows me place the whole framework into node-inspector and do interactive debugging while things are executing. You are able to set breakpoints etc. as well as see the debug output as if the (--debug option) had been selected. You start the system with alternate command: sls-debug. I will post it as a pull request for review.
flomotlik commentedon Aug 5, 2016
I like the
--log-levelidea. At the moment I don't think we should put too much time into it ourselves, but it would be great as a contribution from the community if somebody wants to pick it up.15 remaining items
fredericbarthelet commentedon May 10, 2020
Following @medikoo recommendations, I updated my PR #7658 in order to use
LOG_DEBUGnamespace value to output command/hook lifecycle in the terminal for the requested serverless command.The way I implemented it is very simple, juste checking for this env var value before writing lifecycle to console.
All PRs linked to this conversation stalled, and I imagine my simple solution to be too simple for the task at hand here. However, I would be happy to help implementing lifecycle debut print feature following your recommendations, if any :) Any feedback on my PR of what I should develop for this to be integrated ?
medikoo commentedon May 11, 2020
@fredericbarthelet This PR is about improving how we handle logs in general (by introducing real log levels and namespaces).
Lifecycle logging could be first one to get advantage of the feature. However first we'd need at least minimal configuration of a new logger.
Technically just initializing log-node writter in
bin/serverless.jswill do most of the job. However it'll be good to fine tune the writer, so logs output style resemble one we have now (we should not introduce a dramatic change of how logs look).Having that logs for lifecycle engine could be configure just with:
Note that also debug branch, has hardcoded lifecycle logs - it serves as a temporary workaround, until we have them naturally provided with new log engine
fredericbarthelet commentedon May 22, 2020
@medikoo, I implemented the feature using log and log-node.
It works as expected and produces outputs on the terminal based on
LOG_DEBUGandLOG_LEVELenv vars. However, as you pointed out, the writer output styles is far from existing Serverless logs style. I did not find any option other thandefaultNamespacewithin the writter to be able to fine tune it.While searching for such a way to customize log outputs, I found this neat cli logger called signale which allows output style configuration via JSON out of the box. It misses the automatic use of both previously mentioned env vars, but this could be implemented directly within the logger configuration. WDYT of using such logging library ? Should I stick with log-node writter and make a PR on it as well to allow style configuration options ?
medikoo commentedon May 22, 2020
Yes, I believe we need to prepare our own custom writer (e.g.
log-serverless) that derives fromlog-nodeand tweaks needed parts. I'll try to prepare one soon, and then we'd be able to jump on it.I'll post it here once it's ready
medikoo commentedon Dec 6, 2021
Closing as that was addressed in context of #9860