Python Forum
What is the best way to set application-wide config values?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What is the best way to set application-wide config values?
#1
I want to write a custom logger and I want to configure the logger once, and import the logger in multiple classes. I would like to do this without using the singleton decorator. The default logger (https://docs.python.org/2/howto/logging....le-modules)[supports logging] from multiple modules, but I'm not sure how this is accomplished. If I have an application where I want to start the application, set the configuration for my own module, and import that module into other classes in the application so that I an access the configuration information, what is the best way to accomplish that?
Reply
#2
(May-07-2020, 04:59 PM)ajorona Wrote: I want to write a custom logger
And why would you want to reinvent the wheel? Use the built-in module and customize the logger to fit your needs.

Also, you link to python2 docs. You should work with python3, not python2
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to transform from wide to long format in python shantanu97 1 1,659 Nov-21-2021, 11:53 AM
Last Post: buran
  Updating a config file [solved] ebolisa 8 2,591 Nov-04-2021, 10:20 AM
Last Post: Gribouillis
  How to send data from a python application to an external application aditya_rajiv 1 2,181 Jul-26-2021, 06:00 AM
Last Post: ndc85430
  Is there a library for recursive object creation using config objects johsmi96 0 1,853 May-03-2021, 08:09 PM
Last Post: johsmi96
  help with pytesseract.image_to_string(savedImage, config='--psm 11')iamge to string korenron 0 2,706 Apr-29-2021, 10:08 AM
Last Post: korenron
  Importing Program Wide JarredAwesome 4 2,194 Sep-07-2020, 04:34 PM
Last Post: JarredAwesome
  Config file update Olivier74 0 1,482 Aug-18-2020, 03:36 PM
Last Post: Olivier74
  Config file entry as list versus string? taziuk 2 1,829 Apr-25-2020, 12:01 PM
Last Post: ndc85430
  output a list of random numbers 'x' columns wide adityavpratap 4 3,000 Jan-13-2020, 05:32 PM
Last Post: perfringo
  logging: child module unable to get parent config jerryxiao 3 3,372 Apr-09-2019, 04:17 AM
Last Post: jerryxiao

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020