File: _common.py

package info (click to toggle)
python-quamash 0.6.1~dfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 204 kB
  • sloc: python: 1,290; sh: 4; makefile: 2
file content (18 lines) | stat: -rw-r--r-- 512 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# © 2014 Mark Harviston <mark.harviston@gmail.com>
# © 2014 Arve Knudsen <arve.knudsen@gmail.com>
# BSD License
"""Mostly irrelevant, but useful utilities common to UNIX and Windows."""
import logging


def with_logger(cls):
	"""Class decorator to add a logger to a class."""
	attr_name = '_logger'
	cls_name = cls.__qualname__
	module = cls.__module__
	if module is not None:
		cls_name = module + '.' + cls_name
	else:
		raise AssertionError
	setattr(cls, attr_name, logging.getLogger(cls_name))
	return cls