ATLAS Offline Software
Loading...
Searching...
No Matches
TileCalibLogger.py
Go to the documentation of this file.
1#!/bin/env python
2
3# Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
4# TileCalibLogger.py
5# Nils Gollub <nils.gollub@cern.ch>, 2007-11-29
6
7import logging
8NAMELENGTH = 15
9
10#_____________________________________________________________________
11def setupFormat(lvl=logging.INFO):
12 myFormat = "%%(name)-%is: %%(levelname)-8s %%(message)s" % NAMELENGTH
13 logging.basicConfig(format=myFormat, level=lvl)
14
15#_____________________________________________________________________
16def getLogger(name="TileCalib"):
17 if len(name)>NAMELENGTH:
18 name = "..."+name[-NAMELENGTH+3:]
19 return logging.getLogger(name)
20
21#_____________________________________________________________________
23 """
24 Base class, providing logging functionality
25 """
26 __slots__ = ["_log"]
27 def __init__(self, name, lvl=logging.INFO):
28 self._log = getLogger(name)
29 self.setLogLvl(lvl)
30 def setLogLvl(self, lvl):
31 self._log.setLevel(lvl)
32 def getLogLvl(self, lvl):
33 self._log.getEffectiveLevel()
34 def log(self):
35 return self._log
36
37
38#=== setup format
__init__(self, name, lvl=logging.INFO)
setupFormat(lvl=logging.INFO)
getLogger(name="TileCalib")