Coverage for python/lsst/pipe/base/task_logging.py: 83%
6 statements
« prev ^ index » next coverage.py v6.4.1, created at 2022-06-28 02:09 -0700
« prev ^ index » next coverage.py v6.4.1, created at 2022-06-28 02:09 -0700
1# This file is part of pipe_base.
2#
3# Developed for the LSST Data Management System.
4# This product includes software developed by the LSST Project
5# (https://www.lsst.org).
6# See the COPYRIGHT file at the top-level directory of this distribution
7# for details of code ownership.
8#
9# This program is free software: you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation, either version 3 of the License, or
12# (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program. If not, see <https://www.gnu.org/licenses/>.
22__all__ = ("TRACE", "VERBOSE", "getTaskLogger")
24from deprecated.sphinx import deprecated
25from lsst.utils.logging import TRACE, VERBOSE, getLogger
28@deprecated(
29 reason="getTaskLogger has been replaced by lsst.utils.logging.getLogger. Will be removed after v24.",
30 version="v24",
31 category=FutureWarning,
32)
33def getTaskLogger(name=None, logger=None):
34 """Get a logger compatible with LSST usage.
36 Parameters
37 ----------
38 name : `str`, optional
39 Name of the logger. Root logger if `None`.
40 logger : `logging.Logger`
41 If given the logger is converted to the relevant logger class.
42 If ``name`` is given the logger is assumed to be a child of the
43 supplied logger.
45 Returns
46 -------
47 logger : `lsst.utils.logging.LsstLogAdapter`
48 The relevant logger.
50 Notes
51 -----
52 A `logging.LoggerAdapter` is used since it is easier to provide a more
53 uniform interface than when using `logging.setLoggerClass`. An adapter
54 can be wrapped around the root logger and the `~logging.setLoggerClass`
55 will return the logger first given that name even if the name was
56 used before the `Task` was created.
57 """
58 return getLogger(name=name, logger=logger)