[h5py] 321/455: Eradicate logging
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Thu Jul 2 18:19:46 UTC 2015
This is an automated email from the git hooks/post-receive script.
ghisvail-guest pushed a commit to annotated tag 1.3.0
in repository h5py.
commit 71bd0670fea8ce2630a4548135b12dcb9f681d3c
Author: andrewcollette <andrew.collette at gmail.com>
Date: Tue Nov 24 01:48:02 2009 +0000
Eradicate logging
---
h5py/_sync.py | 117 ----------------------------------------------------------
h5py/h5.pyx | 43 ---------------------
h5py/h5f.pyx | 9 -----
setup.py | 18 +++------
4 files changed, 6 insertions(+), 181 deletions(-)
diff --git a/h5py/_sync.py b/h5py/_sync.py
deleted file mode 100644
index 8be5f8b..0000000
--- a/h5py/_sync.py
+++ /dev/null
@@ -1,117 +0,0 @@
-#+
-#
-# This file is part of h5py, a low-level Python interface to the HDF5 library.
-#
-# Copyright (C) 2008 Andrew Collette
-# http://h5py.alfven.org
-# License: BSD (See LICENSE.txt for full license)
-#
-# $Date$
-#
-#-
-
-from __future__ import with_statement
-
-import logging
-from functools import update_wrapper
-
-from h5py.h5 import get_phil, get_config
-
-phil = get_phil()
-config = get_config()
-logger = logging.getLogger('h5py.functions')
-logging.getLogger('h5py.identifiers').disabled = True
-
-def uw_apply(wrap, func):
- # Cython methods don't have a "module" attribute for some reason
- if hasattr(func, '__module__'):
- update_wrapper(wrap, func, assigned=('__module__', '__name__', '__doc__'))
- else:
- update_wrapper(wrap, func, assigned=('__name__','__doc__'))
-
-def funcname(func):
-
- if hasattr(func, '__objclass__'):
- fullname = "%s.%s.%s" % (func.__objclass__.__module__, func.__objclass__.__name__, func.__name__)
- elif hasattr(func, '__module__') and func.__module__ is not None:
- fullname = "%s.%s" % (func.__module__, func.__name__)
- elif hasattr(func, '__self__'):
- fullname = "%s.%s" % (func.__self__.__class__.__name__, func.__name__)
- else:
- print "unknown"
- fullname = func.__name__
-
- return fullname
-
-if config.DEBUG:
-
- indent = 0
-
- def nosync(func):
-
- fname = funcname(func)
-
- def wrap(*args, **kwds):
- global indent
- argstr = ", ".join("%r" % (arg,) for arg in args)
- kwstr = ", ".join("%s=%r" % (x,y) for x, y in kwds.iteritems())
- logger.debug(" "*indent+"%s(%s%s)" % (fname, argstr, kwstr))
- indent += 4
- try:
- retval = func(*args, **kwds)
- except BaseException, e:
- logger.debug(" "*indent+'! %s("%s")' % (e.__class__.__name__, e))
- raise
- else:
- if retval is not None:
- logger.debug(" "*(indent)+"=> %r" % (retval,))
- finally:
- indent -= 4
- return retval
- uw_apply(wrap, func)
- return wrap
-
- def sync(func):
-
- func = nosync(func) #enables logging and updates __doc__, etc.
-
- def wrap(*args, **kwds):
- with phil:
- return func(*args, **kwds)
- return wrap
-
-else:
-
- def sync(func):
- def wrap(*args, **kwds):
- with phil:
- return func(*args, **kwds)
- uw_apply(wrap, func)
- return wrap
-
- def nosync(func):
- def wrap(*args, **kwds):
- return func(*args, **kwds)
- uw_apply(wrap, func)
- return wrap
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/h5py/h5.pyx b/h5py/h5.pyx
index 9b12176..5527563 100644
--- a/h5py/h5.pyx
+++ b/h5py/h5.pyx
@@ -83,9 +83,6 @@ cdef class H5PYConfig:
API_18 (T/F, readonly)
If the HDF5 1.8 API available?
-
- DEBUG (integer, readonly)
- Gives the debug logging level, or 0 if built without logging.
complex_names (tuple, r/w)
Settable 2-tuple controlling how complex numbers are saved.
@@ -99,7 +96,6 @@ cdef class H5PYConfig:
def __init__(self):
self.API_16 = bool(H5PY_16API)
self.API_18 = bool(H5PY_18API)
- self.DEBUG = H5PY_DEBUG
self._r_name = 'r'
self._i_name = 'i'
self._f_name = 'FALSE'
@@ -165,32 +161,6 @@ cpdef H5PYConfig get_config():
"""
return cfg
-# === Bootstrap diagnostics and threading, before decorator is defined ===
-
-IF H5PY_DEBUG:
- import logging
- for x in ('h5py.library', 'h5py.identifiers', 'h5py.functions', 'h5py.threads'):
- l = logging.getLogger(x)
- l.setLevel(H5PY_DEBUG)
- l.addHandler(logging.StreamHandler())
- log_lib = logging.getLogger('h5py.library')
- log_ident = logging.getLogger('h5py.identifiers')
- log_threads = logging.getLogger('h5py.threads')
-
-
-def loglevel(lev):
- """ (INT lev)
-
- Shortcut to set the logging level on all library streams.
- Does nothing if not built in debug mode.
- """
- IF H5PY_DEBUG:
- for x in ('h5py.identifiers', 'h5py.functions', 'h5py.threads'):
- l = logging.getLogger(x)
- l.setLevel(lev)
- ELSE:
- pass
-
# === Public C API for object identifiers =====================================
cdef class ObjectID:
@@ -230,15 +200,9 @@ cdef class ObjectID:
self._locked = 0
self.id = id_
- IF H5PY_DEBUG:
- def __init__(self, hid_t id_):
- log_ident.debug("+ %s" % str(self))
-
def __dealloc__(self):
""" Automatically decrefs the ID, if it's valid. """
- IF H5PY_DEBUG:
- log_ident.debug("- %d" % self.id)
if (not self._locked) and H5Iget_type(self.id) != H5I_BADID:
H5Idec_ref(self.id)
@@ -254,8 +218,6 @@ cdef class ObjectID:
if self._valid and not self._locked:
H5Iinc_ref(self.id)
copy._locked = self._locked
- IF H5PY_DEBUG:
- log_ident.debug("c %s" % str(self))
return copy
def __richcmp__(self, object other, int how):
@@ -351,9 +313,6 @@ def _exithack():
cdef hid_t *objs
count = H5Fget_obj_count(H5F_OBJ_ALL, H5F_OBJ_ALL)
-
- IF H5PY_DEBUG:
- log_lib.info("* h5py is shutting down (closing %d leftover IDs)" % count)
if count > 0:
objs = <hid_t*>malloc(sizeof(hid_t)*count)
@@ -376,8 +335,6 @@ cdef int init_hdf5() except -1:
import _conv
if not hdf5_inited:
- IF H5PY_DEBUG:
- log_lib.info("* Initializing h5py library")
if H5open() < 0:
raise RuntimeError("Failed to initialize the HDF5 library.")
register_thread()
diff --git a/h5py/h5f.pyx b/h5py/h5f.pyx
index aa0b5cc..9e77b5c 100644
--- a/h5py/h5f.pyx
+++ b/h5py/h5f.pyx
@@ -65,9 +65,6 @@ def open(char* name, unsigned int flags=H5F_ACC_RDWR, PropFAID fapl=None):
Keyword fapl may be a file access property list.
"""
- IF H5PY_DEBUG:
- import logging
- logging.getLogger('h5py.library').info('* Opening file %s' % name)
return FileID(H5Fopen(name, flags, pdefault(fapl)))
@@ -87,9 +84,6 @@ def create(char* name, int flags=H5F_ACC_TRUNC, PropFCID fcpl=None,
To keep the behavior in line with that of Python's built-in functions,
the default is ACC_TRUNC. Be careful!
"""
- IF H5PY_DEBUG:
- import logging
- logging.getLogger('h5py.library').info('* Creating file %s' % name)
return FileID(H5Fcreate(name, flags, pdefault(fcpl), pdefault(fapl)))
@@ -264,9 +258,6 @@ cdef class FileID(ObjectID):
physical file might not be closed until all remaining open
identifiers are freed.
"""
- IF H5PY_DEBUG:
- import logging
- logging.getLogger('h5py.library').info('* Closing file %s' % self.name)
H5Fclose(self.id)
diff --git a/setup.py b/setup.py
index 678350b..1b89544 100644
--- a/setup.py
+++ b/setup.py
@@ -301,16 +301,14 @@ class cython(Command):
description = "Rebuild Cython-generated C files"
- user_options = [('diag', 'd', 'Enable library debug logging'),
- ('api16', '6', 'Only build version 1.6'),
+ user_options = [('api16', '6', 'Only build version 1.6'),
('api18', '8', 'Only build version 1.8'),
('force', 'f', 'Bypass timestamp checking'),
('clean', 'c', 'Clean up Cython files')]
- boolean_options = ['diag', 'force', 'clean']
+ boolean_options = ['force', 'clean']
def initialize_options(self):
- self.diag = None
self.api16 = None
self.api18 = None
self.force = False
@@ -345,7 +343,7 @@ class cython(Command):
print "Rebuilding Cython files (this may take a few minutes)..."
- def cythonize(api, diag):
+ def cythonize(api):
outpath = localpath('api%d' % api)
self.checkdir(outpath)
@@ -358,12 +356,9 @@ DEF H5PY_VERSION = "%(VERSION)s"
DEF H5PY_API = %(API_MAX)d # Highest API level (i.e. 18 or 16)
DEF H5PY_16API = %(API_16)d # 1.6.X API available (always true, for now)
DEF H5PY_18API = %(API_18)d # 1.8.X API available
-
-DEF H5PY_DEBUG = %(DEBUG)d # Logging-level number, or 0 to disable
"""
pxi_str %= {"VERSION": VERSION, "API_MAX": api,
- "API_16": True, "API_18": api == 18,
- "DEBUG": 10 if diag else 0}
+ "API_16": True, "API_18": api == 18}
f = open(op.join(outpath, 'config.pxi'),'w')
f.write(pxi_str)
@@ -371,7 +366,6 @@ DEF H5PY_DEBUG = %(DEBUG)d # Logging-level number, or 0 to disable
debug(" Cython: %s" % Version.version)
debug(" API level: %d" % api)
- debug(" Diagnostic mode: %s" % ('yes' if diag else 'no'))
for module in MODULES:
@@ -391,9 +385,9 @@ DEF H5PY_DEBUG = %(DEBUG)d # Logging-level number, or 0 to disable
# end "def cythonize(...)"
if self.api16:
- cythonize(16, self.diag)
+ cythonize(16)
if self.api18:
- cythonize(18, self.diag)
+ cythonize(18)
class hbuild_ext(build_ext):
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/h5py.git
More information about the debian-science-commits
mailing list