Welcome to

The Conxsys Blog

Thoughts on Conxsys, Notes/Domino, LotusScript, & Technology

Flow: Advanced LotusScript Logging

April 8th, 2008 by Corey Davis

Notes 8 LogoToday I am happy to introduce Flow, a full-featured logging engine for LotusScript. Originally named Extended Logging and used in our Logistic and VantagePoint applications, I have decided to release it as a free open-source project on OpenNTF.org.

Now renamed to Flow, this LotusScript class-family allows for rich-text logging to documents and e-mail messages, plain-text files, the Domino console and Notes status bar, as well as to message dialog boxes. Easy to setup and configure — you can be logging in less than four lines of code! — Flow will help you standardize your Lotus Notes application logging needs.

Flow logs events and errors in a streaming style similar to the Domino console or log.nsf database allowing you to follow the step-by-step process that your applications take as they perform their processing. The amount of detail logged is fully configurable and easily modifiable.

Over the past couple months as I have been putting in the finishing touches and getting this ready for public consumption, I have discussed this project with some in the Lotus community and two questions keep coming up. I will answer them here.

How is this different from OpenLog?
Julian’s OpenLog project is undoubtedly fantastic. The original Extended Logging code was created before I had ever heard of OpenLog. When I did hear of it and subsequently tried it out, I found that it did not meet my logging needs. No disrespect meant to Julian — dude, I love your work! — but I really needed to log multiple events and errors in one document as opposed to each event and error having it’s own document. For a product like Logistic, OpenLog simply was not viable. It comes down to a difference in methodology. If OpenLog works for you then I would say stick with it because Flow is not meant as a replacement to OpenLog.

Okay, then how is it different from the NotesLog class?
The NotesLog class provided the type of “streaming” logging that I needed, and I did use it in the pre-Alpha development versions of Logistic. For the final product, however, I really wanted to provide a more readable, user-friendly logging experience. Given that a product like Logistic was going to touch and interact with user’s mail databases and, ultimately, delete documents, it seemed obvious to me that logging was a crucial design point. My customers would require detailed knowledge of what Logistic was doing and why certain documents were targeted for deletion. Therefore, I needed things like rich-text logging so that I could assign different colors for readability, and logging levels so that my customers could chose to have Minimal logging enabled when everything worked well but could turn up the detail level to Normal, Verbose, or Debug in order to get a more detailed, step-by-step flow if events if things went wrong or there were questions about why it processed the way it did. The NotesLog could not give me what I needed.

I assume others must be in a similar predicament as I, therefore I have decided that it is high time for me to give back to the Lotus community by sharing some of my code with all of you. I hope that some of you find Flow useful and will contribute back your modifications in order to make it better. I also hope to share more “glue code” that is used in Conxsys applications in the months and years to come.

You can find the Flow project on the OpenNTF.org site. If you have any questions feel free to contact me or leave a response here.


Tags: , , , ,
Posted in Conxsys, 11,654 views, 11 Comments
Digg This Submit to del.icio.us Submit to Technorati  

11 Responses

  1. Julian Robichaux Says:

    Sounds great Corey! Can’t wait to take a look.

    - Julian

  2. Corey Says:

    Thanks, Julian! Can’t wait to hear what you think.

  3. Mark Barton Says:

    Corey,

    In the advance agent example if I rem out or set the value to false – logger.LogEventsToMail = False I still get the log file emailed to me even if there is no error.

    The only way I can get the email to stop is to also set the logger.LogErrorsToMail = False

    Any ideas?

    Mark

  4. Corey Says:

    Mark,

    That was actually intentional. I always put some starting and ending text in my agents (e.g. “Starting Job” and “Ending Job”) set to Minimal so that there is always something logged even if it is just that starting and ending text. That is useful to me so that I know the agent started and completed. I also tend to fall into the trap of making assumptions that other people do what I do.

    Flow’s current behavior is probably not how most people would assume it would work. I will modify it so that it will not save any documents or send e-mail if an event or error was not logged. I will post a comment here when the fix is available.

    And, by the way, thank you for bringing this to my attention!

  5. Stefaan Somers Says:

    How do you use it in a self build LotusScript class???

    For example I have the followinf agent with print statements I want to replace with your framework
    Agent :
    Print “Creating car”
    Dim myCar as Car
    Set myCar = New Car()
    call myCar.start

    Public Class Car

    Public Sub start()
    Print “Car is being started”
    End Sub

    Public Sub new()
    Print “Car instance is being created”
    End Sub

    Public Sub delete()
    End Sub

    End Class

  6. Corey Davis Says:

    Stefaan,

    That is a good question. The way you handle this is by instantiating the FlowEngine in your agent and passing it to your class in the New subroutine like this:

    Use “FlowEngine”
    Dim logger as new FlowEngine()
    Call logger.LogEvent(“Creating car”, LOG_LEVEL_MINIMAL)
    Dim myCar as Car
    Set myCar = New Car(logger)
    call myCar.start
    Public Class Car
    Public Sub start()
    Call logger.LogEvent(“Car is being started”, LOG_LEVEL_MINIMAL)
    End Sub
    Public Sub new(logger as FlowEngine)
    Call logger.LogEvent(“Car instance is being created”, LOG_LEVEL_MINIMAL)
    End Sub
    Public Sub delete()
    End Sub
    End Class

  7. Stefaan Somers Says:

    Corey,

    this means hower that evey peice of code that uses this class, also needs to have a variable NotesLog. Isn’t there an easier way??

  8. Corey Davis Says:

    Stefaan,

    You could write the class to handle all of the logging internally without modifying the agent like this:

    Agent:
    Dim myCar as Car
    Set myCar = New Car()
    call myCar.start

    Car Script Library:
    Use “FlowEngine”
    Public Class Car
    Private logger as New FlowEngine()
    Public Sub start()
    Call logger.LogEvent(“Car is being started”, LOG_LEVEL_MINIMAL)
    End Sub
    Public Sub New()
    Call logger.LogEvent(“Car instance is being created”, LOG_LEVEL_MINIMAL)
    End Sub
    Public Sub delete()
    End Sub
    End Class

    But, what if your agent were to introduce a second Car object?

    Agent:
    Dim myCar as Car
    Dim myCar2 as Car
    Set myCar = New Car()
    Set myCar2 = New Car()
    call myCar.start
    call myCar2.start

    Because the FlowEngine object is instantied at the object (Car) level, then *each* instantiation of a new Car will create a *its own* log document. In the example above, you will end up with a log document for myCar and another separate log document for myCar2. If that it what you want, then you can do that.

    But, if what you really want is for all of the data to be written to the same log document, then new objects of Car will need to *share* the same FlowEngine object. This is not a limitation of Flow, this is how sharing objects in LotusScript (and most other OOP languages) work. To share the log object, you have to instantiate it outside of the Car object as I did by modifying the agent code. By instantiating as high as possible in the structure (in this case in an agent) then you have more flexability and can share that single object with any other custom object that you create. Yes, it is a little more work, but in the end you have disperate class code that is fully capable of writing to the same log document which can give you as much or as little as information about the flow of events in your code as you choose.

  9. yestotalk.com Says:

    Excellent goods from you, man. I’ve understand your stuff previous to and you’re just too great.
    I really like what you have acquired here, certainly
    like what you’re saying and the way in which you say it.
    You make it enjoyable and you still care for to keep
    it sensible. I can’t wait to read much more from you.
    This is actually a terrific site.

  10. www.youtube.Com Says:

    Hello there. Simply wished to inquire a fast question. I
    am just assembling my blog as well as want to understand wherever
    you got your style? Was that free of charge? Or even had been it paid for?
    I cannot appear to uncover anything competitive with this one, therefore hopefully you are able to let me understand.
    Appreciate it. PS, my sorry. The english language is just not the initial
    vocabulary.

  11. August Ames in gym Says:

    As it starts to get warm in the spring and summer, the last thing I wanted to do
    was spend more time at the gym. This is why many
    people have actually engaged into exercise regimen to help their bodies become stronger and fitter.
    Still, if somebody can spend time as well
    as have discipline, he or she may find out that aren’t simply low-priced means but likewise more efficient than the gym.

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.

CC-GNU GPL Creative Commons License
The Conxsys Blog by Corey Davis is licensed under a Creative Commons Attribution 3.0 Unported License unless otherwise specified. Based on a work at conxsys.com/blog. All code on this blog is licensed under the CC-GNU GPL version 2.0 or later unless otherwise specified.


Copyright © 2006-2010 by Conxsys | Login | Powered by Wordpress | Template based on a design by Design4