Skip to content

Commit

Permalink
Update the infer README.md logging example (#250)
Browse files Browse the repository at this point in the history
Update the infer/README.md logging example from the old way
`ctx.Logf(diag.Warning, "file %q already deleted", props.Path)` to the
new way `p.GetLogger(ctx).Warningf("file %q already deleted",
props.Path)`
  • Loading branch information
zbuchheit authored Jul 22, 2024
1 parent fc4918d commit 889832f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions infer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,14 +203,14 @@ that by implementing the `Delete` method:
func (*File) Delete(ctx context.Context, id string, props FileState) error {
err := os.Remove(props.Path)
if os.IsNotExist(err) {
ctx.Logf(diag.Warning, "file %q already deleted", props.Path)
p.GetLogger(ctx).Warningf("file %q already deleted", props.Path)
err = nil
}
return err
}
```

Note that we can issue diagnostics to the user via the passed on `Context`. The
Note that we can issue diagnostics to the user via the `p.GetLogger(ctx)` function. The
diagnostic messages are tied to the resource that the method is called on, and pulumi
will group them nicely:

Expand Down

0 comments on commit 889832f

Please sign in to comment.