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 | 31 |
Tags
- 오블완
- 취미생활
- raspberry pi
- 월패드
- homebridge
- ConnectedHomeIP
- RS-485
- esp32
- 현대통신
- 해외주식
- 마이크로소프트
- 미국주식
- Espressif
- 라즈베리파이
- Home Assistant
- 국내주식
- matter
- 매터
- 힐스테이트 광교산
- 파이썬
- Apple
- Python
- 공모주
- 나스닥
- MQTT
- 티스토리챌린지
- 배당
- 애플
- 홈네트워크
- Bestin
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