[Pharo-dev] What the state of unifying Beacon with SystemLogger?

Norbert Hartl norbert at hartl.name
Wed Apr 20 04:53:50 EDT 2016


Denis,


> Am 18.04.2016 um 18:28 schrieb Denis Kudriashov <dionisiydk at gmail.com>:
> 
> Hello.
> 
> Year ago Beacon and SystemLogger were announced. There was big discussion about them. And there were plans to provide single solution. What was done around that? 
> 
we had some talks but nothing happened afterwards. The whole discussion went somehow off track. The good part is that we had a conclusion that we want to log objects instead of strings. The bad part is that we forget to talk about the "logging" part of it. And the discussion and actions are not a good example for collaboration rather the opposite.

The SystemLogger started as a project to build a small core about what is usually done in logging frameworks. Usually log messages are strings with a severity level like error, warn, etc attached. The log messages are dispatched to a central location. At that location there is a bunch of log message consumers that filter by severity level or other criteria. This filtering consumers are attached to sinks that store the messages in some format somewhere.  The sinks implement formatting and adaptation to storage like files, syslog, database,…

We want to do better and we care about objects instead of strings. In case of writing to a file it will be a string anyway. So we can see that "logging objects" means that the distribution of a log through the system should happen as objects with rich interfaces. And it means that the conversion to a string should happen (if needed at all) at the latest possible moment. So in my opinion the logging framework should support:

- having an easy way to emit any kind of log object. The most basic thing a log entity should have is a timestamp. Around it there could be some common use cases but most of it is application specific.
- multiple log consumers
- filtering of log entities. IMO this includes filtering of objects you log to store. In a typical scenario where you would have a severity level you only want to log certain messages. This can also include filtering for special types of objects. That would mean you filter the kind of objects the consumer can understand
- storage facilities. It is quite important to support files storage in many flavors, logging to syslog, logging to database etc. Without that you are just logging in memory and I'm not sure if a lot of people would agree that this is what is meant by using the word logging 

As an example I can put one of my projects where I use SystemLogger. When sending a push notification I log/emit an object/event of type COMessageSent with sublcasses for apple, google, etc. It is emitted to a central location. In SystemLogger there a three loggers configured. One is in memory and counts the number of events per class. One takes the object, converts it into a short string representation like "apple push sent to XXXX" and sends it via syslog/UDP to a central logging server. Finally the third one takes the object, converts it to json and stores the json in a elasticsearch database. The database allows me to do all sorts of statistical analysis of the data over a long time frame such as number of push messages per month for one year. Which looks like this

 

So if you take my point of view then Beacon is pretty useless. SystemLogger and Beacon both use a singleton to dispatch log entities. In SystemLogger has own implementation of registry for that loggers. Beacon uses Announcements for it. That's basically the difference. I like the idea of using Announcements and not invent yet another distribution mechanism. But with Announcements you can only filter by class and not by instance. So it cannot do what system logger can do. Doru writes that he is working on that and it would be great. Although I have doubt this can be done performant I would be lucky to have it. 
On the other hand Beacon implements a handful of classes for some use cases but nothing more. So I see Svens point that you don't need it really because Announcements are there anyway and most of the stuff is application specific so I can just do that without having to integrate a "framework".

> What exactly should be merged between this libraries? Was Beacon or SystemLogger planned to be end solution? 
> 
I'm not sure anymore. I can see some good things in Beacon that enable to register a logger for part of the execution. The drawback is that if you think about output facilities like log files there is no central place to attach it. And I surely don't want to have log configurations in the middle of my code. Beacon is not well thought in that direction, yet. 
IMHO I'd like to have a SystemLogger with the distribution of objects like it is done in Beacon. Filtering is to be solved. This is hard to do with Announcements and to be honest I don't really like it how it is done in SystemLogger. 

> We definitely need legacy logging tool for Pharo. And I am going to work on this direction.
> Personally I prefer metaphor and names from Beacon. But both libraries implement similar idea. 
> 
Agreed. As I said above. If you take to point of view from legacy logging tool Beacon is not a big help. But the ideas in it are good and should be integrated somewhere. If you are talking about legacy tooling it might ok to use the terms logging as well, no? I personally like the work Beacon but in my opinion it is  wrong for this purpose. A beacon sends a uniform signal in order to be discovered. The Beacon code sends signals to a beacon. And I can register at the beacon in which signals I'm interested in. Feels wrong to me.

Norbert

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pharo.org/pipermail/pharo-dev_lists.pharo.org/attachments/20160420/4355a773/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Bildschirmfoto 2016-04-20 um 10.24.36.png
Type: image/png
Size: 67551 bytes
Desc: not available
URL: <http://lists.pharo.org/pipermail/pharo-dev_lists.pharo.org/attachments/20160420/4355a773/attachment.png>


More information about the Pharo-dev mailing list