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

本站现有博文334篇,共被浏览933048

本站已经建立2642天!

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