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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow fallback for Pulumi.Log when used outside a Pulumi run #152

Open
thecodetinker opened this issue Jul 3, 2023 · 1 comment
Open
Labels
kind/enhancement Improvements or new features

Comments

@thecodetinker
Copy link

Hello!

  • Vote on this issue by adding a 馃憤 reaction
  • If you want to implement this feature, comment to let us know (we'll work with you on design, scheduling, etc.)

Issue details

Our Pulumi C# code contains a number of helper classes, for example one that calculates IP CIDR Ranges. These have unit tests independent of Pulumi, and need to do some logging. The nice thing to do would be to use Pulumi.Log in the code, however this fails during execution outside of a Pulumi stack.

System.InvalidOperationException
Trying to acquire Deployment.Instance before 'Run' was called.

As far as I can tell, there is no way to tell whether or not Pulumi is running or not so it's hard to even fall back to Console. The 'proper' answer may be to start injecting ILogger with some kind of dynamic configuration, but this feels a little bit like overkill when it would be nice to just he Pulumi.Log everywhere but have it behave itself when called outside of Pulumi run.

Affected area/feature

Logging.

@thecodetinker thecodetinker added kind/enhancement Improvements or new features needs-triage Needs attention from the triage team labels Jul 3, 2023
@Frassle Frassle transferred this issue from pulumi/pulumi Jul 3, 2023
@dixler dixler removed the needs-triage Needs attention from the triage team label Jul 7, 2023
@dixler
Copy link
Contributor

dixler commented Jul 7, 2023

Hi, thanks for filing this. Will discuss with the team.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement Improvements or new features
Projects
None yet
Development

No branches or pull requests

2 participants