EADST

Print Info in the Terminal and Save Logs in a File

Print Info in the Terminal and Save Logs in a File

import logging

log_name = "test"
logging.basicConfig(filename="{}.log".format(log_name), format='%(asctime)s %(message)s', filemode='w') 
sh = logging.StreamHandler()
logger=logging.getLogger() 
logger.setLevel(logging.DEBUG) 
logger.addHandler(sh)

logger.debug("Level lowest message") 
logger.info("Regular message") 
logger.warning("Warning message") 
logger.error("Error message") 
logger.critical("Fatal message") 

Reference

Python Logging

相关标签
About Me
XD
Goals determine what you are going to be.
Category
标签云
Anaconda Plotly Breakpoint 音频 GPTQ FP16 LeetCode Algorithm Crawler Tracking CLAP HaggingFace diffusers CTC Docker Video ChatGPT Llama COCO Land Bin NLTK Excel WebCrawler FastAPI 第一性原理 Gemma v0.dev 搞笑 Logo CAM uwsgi Augmentation v2ray LLAMA Tiktoken transformers GGML LoRA CSV Quantize RGB 域名 Git Sklearn 多进程 Image2Text 递归学习法 Hilton Interview tar QWEN Python BTC Use Tensor 算法题 VGG-16 Qwen2.5 PyTorch HuggingFace Transformers Pickle UNIX Pillow Animate Markdown Translation 强化学习 Data Jupyter Distillation Mixtral Clash 净利润 NameSilo Card Qwen2 Numpy Food Math TTS Color FP8 Claude VSCode Dataset Vim API 顶会 Proxy 飞书 图标 News CC git-lfs Quantization Hungarian Domain Jetson Agent 版权 BF16 tqdm YOLO WAN mmap Review Diagram 继承 Paper ONNX 公式 财报 Vmess git Linux TensorRT JSON hf VPN Conda logger Statistics Qwen Firewall Datetime 关于博主 Michelin torchinfo 腾讯云 uWSGI Paddle Plate Shortcut 多线程 PDF Ubuntu SVR Random C++ Pytorch OpenCV Safetensors Heatmap LLM Pandas Knowledge Github EXCEL 图形思考法 printf Attention Website Streamlit 云服务器 FlashAttention RAR Google Miniforge GoogLeNet llama.cpp Rebuttal TSV Zip AI XML Magnet Input GPT4 BeautifulSoup ResNet-50 icon FP64 MD5 OCR PIP Bitcoin Password PDB Nginx GIT Hotel Freesound Cloudreve CUDA CEIR Windows XGBoost ModelScope DeepStream SQLite 报税 NLP Disk Web 签证 OpenAI SPIE Bipartite PyCharm UI TensorFlow Ptyhon Base64 证件照 InvalidArgumentError SAM IndexTTS2 Permission Baidu CV Django Bert DeepSeek Search LaTeX FP32 Template scipy SQL 阿里云
站点统计

本站现有博文324篇,共被浏览809113

本站已经建立2512天!

热门文章
文章归档
回到顶部