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.
Hello!
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.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.