Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^2: Moose based logging question

by jandrew (Chaplain)
on Feb 10, 2014 at 17:53 UTC ( [id://1074293]=note: print w/replies, xml ) Need Help??


in reply to Re: Moose based logging question
in thread Moose based logging question

jellisii2,

My question (and sample code) wasn't intended to be an indictment of Log4perl which is a well written and well thought out program with lots of good community support. I apologize if I did not correctly communicate that earlier. I have included a list below of why I went out on my own designing a new logger but in the end you might be able to chalk it up to a learning experience. For starters tobyink has finally motivated me to learn about and try prototypes, introduced me to the bang bang operator, and pointed me to an intriguing module which is worth the effort all on it's own.

This all started with the question; what if a logger was Moose extensible? But has the additional added functions

  1. Buffer behavior
  2. I wanted a report buffer (default off) for each report name. This allows for some messages to be discarded after they were collected based on branches in the code. A use case for this is when you are recursively parsing some logic but only want to log the actions in the path that yielded results. This is different than a print buffer that always goes to the output but the send is just delayed.

  3. Dedicated Test Module
  4. I wanted a test module that could capture the logged messages prior to final arrival at the destination report. The idea is to leverage the buffer listed above. The value is to test logged output without having to build a report to capture it first.

  5. Headers
  6. I wanted a report output that was smart enough to not re-add the headers each time the report was linked. (Only the first time it was built.)

  7. Custom formatting
  8. I wanted to be able to use method calls and code references when formatting 'Report' output. While my API isn't as mature as Log4perl's 'PatternLayout' it (mostly) supports sprintf formatting.

  9. Moose
  10. The goal is a Moose based logger. You probably already have an opinion on Moose so no further explanation provided. I like Moose and I currently have no plans to switch to Moo but I would convert to the new p5-MOP if when it gets added to the perl core.

  11. Multiple output paths
  12. I wanted a one stop shop for file outputs. I mentally group file outputs from code into two categories. First is 'log_file' output. This is the way that code leaves tracks from the ongoing process that it follows. Second is 'report' output. This is when data is generated by code for consumption elsewhere. Yes, I know that Log::Dispatch already provides this.

  13. I wanted to save some things
    1. flexibility
    2. General flexibility and ease of definition for configuration through either config. files or data structures.

    3. Separation of concerns
    4. Separation of output creation and destination definitions.

    5. name-spaces
    6. Output level screening by name-space and urgency. This includes the possibility of custom level definitions by report name-space.

Ultimately, I guess I prefer perl because we embrace TIMTOWDI. As you will note if you have read my list of reasons I also listed set of behaviours from Log4perl that I tried to preserve. Additionally I am fairly certain that the behaviours I am trying to preserve have been implemented less cleanly than the mainstream loggers. For me the journey is the goal and I'm just trying to have fun on the way.

Replies are listed 'Best First'.
Re^3: Moose based logging question
by jellisii2 (Hermit) on Feb 10, 2014 at 20:52 UTC
    Wanting to reinvent the wheel for personal edification is one thing. Wanting to reinvent the wheel for production code is quite another.

    Good luck on your pursuit, but beware putting it into a major production environment. Someone that's not you will have to maintain it at some point.

    BTW, I have no opinions on any of the OO frameworks for perl. I don't use any of them yet.

      That was really the goal of my question. As I experiment in a way that I find useful I don't want to impose that experiment on anyone else more than I have to for content that I share with others. My personal development style implies some impact but I wanted to minimize that as much as possible if the logger stuff were to finally reach the light of day (CPAN).

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1074293]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (4)
As of 2024-03-29 13:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found