Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-30286: Add VERBOSE log level #527

Merged
merged 3 commits into from
May 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions python/lsst/daf/butler/_butler.py
Expand Up @@ -80,6 +80,7 @@
StorageClassFactory,
Timespan,
ValidationError,
VERBOSE,
)
from .core.repoRelocation import BUTLER_ROOT_TAG
from .core.utils import transactional, getClassOf
Expand Down Expand Up @@ -402,6 +403,8 @@ def makeRepo(root: str, config: Union[Config, str, None] = None,
dimensionConfig = DimensionConfig(dimensionConfig)
Registry.createFromConfig(registryConfig, dimensionConfig=dimensionConfig, butlerRoot=root)

log.log(VERBOSE, "Wrote new Butler configuration file to %s", configURI)

return config

@classmethod
Expand Down
6 changes: 6 additions & 0 deletions python/lsst/daf/butler/cli/cliLog.py
Expand Up @@ -231,6 +231,9 @@ def _getPyLogLevel(level):
numericValue : `int`
The python `logging` numeric value for the log level.
"""
if level == "VERBOSE":
from .. import VERBOSE
return VERBOSE
return getattr(logging, level, None)

@staticmethod
Expand Down Expand Up @@ -262,6 +265,9 @@ def _getLsstLogLevel(level):
level = "FATAL"
elif level == "WARNING":
level = "WARN"
elif level == "VERBOSE":
# LSST log does not yet have verbose defined
return (lsstLog.Log.DEBUG + lsstLog.Log.INFO) // 2
return getattr(lsstLog.Log, level, None)

class ComponentSettings:
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/daf/butler/cli/opt/options.py
Expand Up @@ -94,7 +94,7 @@ def makeCollectionTypes(context, param, value):
datasets_option = MWOptionDecorator("--datasets")


logLevelChoices = ["CRITICAL", "ERROR", "WARNING", "INFO", "DEBUG"]
logLevelChoices = ["CRITICAL", "ERROR", "WARNING", "INFO", "VERBOSE", "DEBUG"]
log_level_option = MWOptionDecorator("--log-level",
callback=partial(split_kv,
choice=click.Choice(logLevelChoices,
Expand Down
1 change: 1 addition & 0 deletions python/lsst/daf/butler/core/__init__.py
Expand Up @@ -30,3 +30,4 @@
from .timespan import *
from .progress import Progress
from . import progress # most symbols are only used by handler implementors
from .logging import *
31 changes: 31 additions & 0 deletions python/lsst/daf/butler/core/logging.py
@@ -0,0 +1,31 @@
# This file is part of daf_butler.
#
# Developed for the LSST Data Management System.
# This product includes software developed by the LSST Project
# (http://www.lsst.org).
# See the COPYRIGHT file at the top-level directory of this distribution
# for details of code ownership.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from __future__ import annotations

__all__ = ("VERBOSE",)

import logging

VERBOSE = (logging.INFO + logging.DEBUG) // 2
"""Verbose log level"""

logging.addLevelName(VERBOSE, "VERBOSE")