Skip to content

Commit

Permalink
bump version, merge pull request #6 from NiftyPET/devel
Browse files Browse the repository at this point in the history
expose `LOG_FORMAT`
  • Loading branch information
casperdcl authored Dec 7, 2020
2 parents 88c500f + 443c192 commit edd18f2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
6 changes: 3 additions & 3 deletions niftypet/ninst/install_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,15 @@ def askdirectory(title="Folder: ", initialdir=None, name=""):
# number of threads
ncpu = multiprocessing.cpu_count()

LOG_FORMAT = "%(levelname)s:%(asctime)s:%(name)s:%(funcName)s\n> %(message)s"


class LogHandler(logging.StreamHandler):
"""Custom formatting"""

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
fmt = logging.Formatter(
"%(levelname)s:%(asctime)s:%(name)s:%(funcName)s\n> %(message)s"
)
fmt = logging.Formatter(LOG_FORMAT)
self.setFormatter(fmt)


Expand Down
24 changes: 11 additions & 13 deletions niftypet/ninst/tools.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
#!/usr/bin/env python3
"""initialise the NiftyPET ninst package"""
__author__ = "Casper O. da Costa-Luis", "Pawel J. Markiewicz"
__date__ = "2020"

import logging
import platform

from tqdm.auto import tqdm

from . import cudasetup as cs
from . import install_tools as tls
from .install_tools import LOG_FORMAT

__all__ = ["LogHandler", "path_resources", "resources", "dev_info", "gpuinfo"]
__all__ = [
"LOG_FORMAT",
"LogHandler",
"path_resources",
"resources",
"dev_info",
"gpuinfo",
]


class LogHandler(logging.StreamHandler):
class LogHandler(tls.LogHandler):
"""Custom formatting and tqdm-compatibility"""

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
fmt = logging.Formatter(
"%(levelname)s:%(asctime)s:%(name)s:%(funcName)s\n> %(message)s"
)
self.setFormatter(fmt)

def handleError(self, record):
super().handleError(record)
raise IOError(record)
Expand Down

0 comments on commit edd18f2

Please sign in to comment.