Inedo Community Forums Forums
    • Recent
    • Tags
    • Popular
    • Login

    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

    Scheduled Pinned Locked Moved Support
    otter
    4 Posts 1 Posters 4 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ? This user is from outside of this forum
      Guest
      last edited by

      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.

      1 Reply Last reply Reply Quote 0
      • ? This user is from outside of this forum
        Guest
        last edited by

        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.

        1 Reply Last reply Reply Quote 0
        • ? This user is from outside of this forum
          Guest
          last edited by

          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?

          1 Reply Last reply Reply Quote 0
          • ? This user is from outside of this forum
            Guest
            last edited by

            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.

            1 Reply Last reply Reply Quote 0

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better 💗

            Register Login
            • 1 / 1
            • First post
              Last post
            Inedo Website Home • Support Home • Code of Conduct • Forums Guide • Documentation