log4mongo / log4mongo-python

python logging handler for mongo database
http://log4mongo.org
Other
111 stars 37 forks source link

Inserting into a particular document #17

Open jorge-lavin opened 8 years ago

jorge-lavin commented 8 years ago

Hi

I was wondering about the idea of inserting the log messages into a particular document in a given collection.

In terms of design I see a downfall, it requires explicitly the document id. For instance via dependency injection, but I'm failing to see to do this in a transparent way (disable / enable handler under demand, without modifying the rest of the logging calls)

Kind regards

oz123 commented 8 years ago

You'll probably have to write your own class that inherits from the main logger class to implement this. In this class you'll have to change write_method to update_one and pass this pass a custom formatter which does not create a new document every time it is invoked.

If you really need this feature you can contact me privately. I am currently busy with higher prio projects.

jorge-lavin commented 8 years ago

@oz123 I may work into this, do you have any contribution policy at this moment?

My main concern is where do you specify the Object Id of the document that you want to the message to be inserted in

oz123 commented 8 years ago

@LavinJ , if you are already inserting a specific Document, you could also overwrite the _id. MongoDB allows that. I outlined more or less how you should do it your feature in my previous comment. As for a policy: keep your code pep-8 compatible, and make sure you submit tested code - e.g. with tests. If you do this, I see no reason, as long as your code does not break other things, why your PR should no be accepted.