Open diegodfsd opened 8 years ago
@diegodfsd currently you would need to extended PetaPoco and override any of the OnExecutedCommand, OnExecutingCommand, OnException, OnConnectionOpened and OnConnectionClosing
methods to implement logging. Obviously, this is not a great solution so I've added to the roadmap to make logging easier
Thank you @pleb I will try think in a how to improve the obvious idea to add log. I'm waiting for a new version.
I think this could lead to a general design on implementing hooks in the pipeline that can be plugged in for monitoring events and avoiding subclassing.
I believe an elegant way could be to have a similar concept of action filters in asp.net mvc. Doing so, you could implement your logging strategy by using attributes / implement specific interfaces.
Here I found some interesting ideas also: https://github.com/TrevorPilley/MicroLite/wiki/Listeners
You can use slf4net.
Or some projects just use their own simple logging façade which is possible to set up by some public static IMyLog Log
property.
To @enrico-padovani comment: IMHO something like
public static Action<string> BeforeDelete;
public static Action AfterDelete;
etc. is simpler and enough solution. When somebody want to chain such Actions he may do it as he likes:
var old = BeforeDelete;
BeforeDelete = s =>
{
// code
if (old != null)
old(s);
// code
};
Hello everyone! Just now I stopped to solve this problem and it is easiest than I thought. The Database class have some extension points and one of that is the OnException virtual method. Besides, there are others two methods OnExecutingCommand and OnExecutedCommand and you can use to debug your queries.
I'm using PetaPoco a few months and now I'm missing integration with log4net for example.