Run update_copyright.py.
[pycomedi.git] / pycomedi / library.pyx
1 # Copyright (C) 2011-2012 W. Trevor King <wking@drexel.edu>
2 #
3 # This file is part of pycomedi.
4 #
5 # pycomedi is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by the
7 # Free Software Foundation, either version 2 of the License, or (at your
8 # option) any later version.
9 #
10 # pycomedi is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 # General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with pycomedi.  If not, see <http://www.gnu.org/licenses/>.
17
18 "Wrap library-wide Comedi functions in a `Device` class"
19
20 import os as _os
21
22 cimport _comedilib_h
23 import constant as _constant
24
25
26 def set_loglevel(level):
27     """Control the verbosity of Comedilib debugging and error messages
28
29     This function affects the output of debugging and error messages
30     from Comedilib. By increasing the loglevel, additional debugging
31     information will be printed. Error and debugging messages are
32     printed to the stream stderr.
33
34     The default loglevel can be set by using the environment variable
35     COMEDI_LOGLEVEL. The default loglevel is 1.
36
37     In order to conserve resources, some debugging information is
38     disabled by default when Comedilib is compiled.
39
40     See `constants.LOGLEVEL` for a list of possible levels and their
41     meanings.
42
43     Return value
44     ============
45
46     This function returns the previous loglevel.
47
48     >>> from constant import LOGLEVEL
49     >>> level = set_loglevel(LOGLEVEL.error)
50     >>> level
51     <_NamedInt bug>
52     >>> set_loglevel(level)
53     <_NamedInt error>
54     """
55     ret = _comedilib_h.comedi_loglevel(_constant.bitwise_value(level))
56     return _constant.LOGLEVEL.index_by_value(ret)