python - Efficient way of setting Logging across a Package Module -


I have a package that has many components in it, which will be of great benefit to logging and outputing useful information.

What I do not want to do is 'Setup' proper logging for each file anywhere with these lines:

  Import logging logging. BasicConfig (level = debug) my_function = logging .getLogger ("my_function") my_class = logging.getLogger ("my_class")  

I have tried some approaches, one of them is a boilerplate code Is adding a class within a utility to a module and try and do something like:

  from importing from importing set_logging ()  

but here As far as the solutions given above do not appear to me and causes the reasons because there is no __ call __ method in the setLogger. What I liked was that my "set_logging" class reads a config file and reads some basic values, it will not make any difference to what level or type of logging format that I wanted to do in the right way Set from

Is there any way to start proper logging across the board in my package? Maybe in the __init __.py file?

  def setlogging (config = none):  

And there should be verbose as possible, this is setlogging (now a function, not a class) looks like this:

/ Div>

If you use the same logger object, "If you want all the code in the module, you just need to make that logger available - see later - and) call

  mylogger.warning (" Attenone! ")  

or logging. Warning & amp; Therefore, the problem is reduced in creating a mylogger object for the entire package and making it available on all modules in the package. (Alternatively, you can use the named loggers with the name that starts with the name of the package, but when it is part of the very logging package functionality,

Then, your util.setlogging function can only be followed, say,

  mylogger = logging.getLogger (package_name))  

and each module that is used Yet does

  util.mylogger.warning (see '') can use.  

And as such, this is being considered as the easiest way, as long as this concept requires that all code in the package be entered in the same way.


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -