Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- 티스토리챌린지
- 매터
- 해외주식
- 퀄컴
- 현대통신
- Apple
- 애플
- 오블완
- 파이썬
- 취미생활
- raspberry pi
- ConnectedHomeIP
- 배당
- Bestin
- 힐스테이트 광교산
- Espressif
- 나스닥
- 홈네트워크
- MQTT
- 코스피
- 미국주식
- Home Assistant
- matter
- 엔비디아
- esp32
- RS-485
- 월패드
- Python
- 국내주식
- homebridge
Archives
- Today
- Total
목록decorator (1)
YOGYUI

파이썬에서 공통으로 사용되는 구문들은 decorator를 활용해서 코드를 간소화할 수 있다 decorator를 활용한 로깅 예시는 다음과 같다 import logging def log(func): """ Log what function is called """ def wrap_log(*args, **kwargs): name = func.__name__ logger = logging.getLogger(name) logger.setLevel(logging.INFO) # add file handler fh = logging.FileHandler("%s.log" % name) fmt = '%(asctime)s - %(name)s - %(levelname)s - %(message)s' formatter = log..
Software/Python
2021. 7. 5. 16:00