-
Notifications
You must be signed in to change notification settings - Fork 273
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
refactor: rename logEntry to log and require for tasks, cmds and actions #292
Conversation
I haven't been able to reproduce the problem with the sections. Something like The issue with indentation of empty entries has been fixed in #302. |
I should also point out that appending nodes to an empty node will indent the child node with respect to the empty parent. So this:
prints this: I'm not indented
I am (since this creates a new, non-empty, child node) ...once #302 has been merged. |
The issue isn't with
I'd expect this to print the full log line, and not omit the section bit. |
You're right. Sorry. Fixed in #316. |
3f0d8e4
to
e745046
Compare
garden-service/src/cli/cli.ts
Outdated
@@ -238,9 +238,11 @@ export class GardenCli { | |||
contextOpts.config = MOCK_CONFIG | |||
} | |||
garden = await Garden.factory(root, contextOpts) | |||
const log = garden.log.info() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Creating this entry here causes some log output to be printed before the command header. Like here:
g build
✖ openfaas--builder → Building
✔ hello-npm-package → Building → Done (took 0.1 sec)
✔ hello-container → Building hello-container:vd8c433df4d... → Done (took 1.2 sec)
Build 🔨```
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. I'll clean that up, and look for similar issues.
970337b
to
d4675fd
Compare
There are currently two issues: Issue 1 The commands use a placeholder log entry (and pass them onwards) whereas the This results in something like this:
or something like this:
depending on whether or not the placeholder log entry is created before or after the Garden class is initialised. In the second example the "Logging stuff..." text gets repeatedly pushed down as more content is printed above which looks a little bit awkward. Solution We can of course move the Issue 2 The logs printed by the placeholder log entry all get indented since they're the children of the empty entry. This is because the original motivation behind allowing entries to create child entries was to create subtasks. Solutions a) Never indent subtasks unless the option is explicitly set (we'd need to update all current subtasks) Note that |
I just update the branch with a fix for issue 2, opting for solution d). So now the main concern is how we handle issue 1. |
Re Issue 1, I think we should have Garden accept a LogEntry instead of a Logger. I think that would sort the issue out more neatly. Then |
3969fa0
to
8c5f91b
Compare
This leverages the recent changes to the logger that allow for empty log entries.
Updated the PR with a commit that I think should solve most of our issues for now. I actually went ahead and remove the ability to create an empty log entry like so: I think that makes things a little bit clearer. My main concern was that a function that receives a log entry doesn't really know what to do with it, since it wasn't clear from the context whether the entry was simply an empty placeholder that should be populated or a task with a spinner that should be updated. Type safety-wise, this is still an issue but at least the intent is a little bit clearer. I think it would make sense to continue to use the Regarding the log entry control flow in general, this is kind of how I envisioned it (and why I've been on the fence about making everything a log entry): const entry = logger.info({msg: "running task..." status: "active"})
try {
// pass the entry along so that it can be updated while task is running
runTask(entry)
} catch (err) {
entry.setState(err.message)
}
entry.setSuccess("whoop") However, the entries are kind of all over the place right now. Also, when everything is an entry, you might end up calling But as I mentioned above, I think some of this can be reigned in by initialising the placeholder entries at the command level and structure the whole thing a bit more. |
@edvald, if the last commit looks okay to you I can go ahead and squash and merge. |
...or perhaps I'll leave is as two commits since there's a lot of conversation around this. |
👍 approved |
This leverages the recent changes to the logger that allow for empty
log entries.
Note: This currently has an issue where the section part of log entries doesn't appear. Need input from @eysi09 to complete this.