Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
84 views
in Technique[技术] by (71.8m points)

python - Django custom command to write a file without debug logging

I have a Django custom command to write csv file. In the code, I use writer = csv.writer(sys.stdout, lineterminator=os.linesep). When I run it with python manage.py write_csv>sample.file, it contains the file content and debug information, like

CDLL(libgeos_c.so.1) Library path: 'libgeos_c.so.1' DLL: <CDLL 'libgeos_c.so.1', handle 5609f58baeb0 at 0x7f03df6b2c88> Trying CDLL(libc.so.6) Library path: 'libc.so.6' DLL: <CDLL 'libc.so.6', handle 7f03ea069450 at 0x7f03df6b2b70> System check identified some issues:

and also the part of logging: logging.info('finish uploading') is in the file. Is there anything I can do to prevent those debug information write to file?

question from:https://stackoverflow.com/questions/65835331/django-custom-command-to-write-a-file-without-debug-logging

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can set verbosity level of your command as documented

 --verbosity {0,1,2,3}, -v {0,1,2,3} 

Specifies the amount of notification and debug information that a command should print to the console.

  • 0 means no output
  • 1 means normal output (default)
  • 2 means verbose output
  • 3 means very verbose output.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...