Welcome to the Inedo Forums! Check out the Forums Guide for help getting started.

If you are experiencing any issues with the forum software, please visit the Contact Form on our website and let us know!

How to log messages from a custom Variable Functions



  • Hi, I am trying to write a custom variable function in Otter. I tried to log some values to the output but I can not figure out how to do it. I tried the following:

    var messenger = new ConsoleMessenger(); messenger.Initialize(); messenger.Message(new SimpleLogMessage(MessageLevel.Information, "Message to log", "", "", context));

    And also:

            Logger.AddMessenger(messenger);            
            Logger.Information("eweweweweDDD");
    

    Nothing seems to work.



  • Variable functions by design do not write to execution logs, since they are evaluated within expressions in an arbitrary order.

    Are you interested more in debug-level logging? We don't have a good mechanism for this in place for the same reason, but ought to be able to come up with something as this is a reasonable situation.



  • Well, to get my thing working I had to throw exceptions with the things I wanted to see for the debugging purposes. My variable function uses BuildMaster API to pull deployables list from an app. Then I will iterate over the result and ensure app pools for all the deployables (which are web apps). Is variable function intended for such a usage?



  • Wow, cool usage! That sound something fairly general-purpose, so we might be able to incorporate it in the InedoCore extension as well.

    But yes, you can certainly use Variable Functions for that purpose; I don't believe we have anything that's quite as advanced, but we had definitely intended for usage like that. We just hadn't put in the logging facilities because none of the functions required logging (and the out-of-order logging may seem very strange). But as Dean mentioned, it's definitely doable.

    Note there is a EvaluateAsync method that might be more suitable for situations like this as well.


Log in to reply
 

Inedo Website HomeSupport HomeCode of ConductForums GuideDocumentation