File: test_logging.py

package info (click to toggle)
python-better-exceptions 0.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 632 kB
  • sloc: python: 620; sh: 108; makefile: 5
file content (50 lines) | stat: -rw-r--r-- 606 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import better_exceptions
import logging

better_exceptions.hook()
logging.basicConfig()

logger = logging.getLogger(__name__)

logging.raiseExceptions = True

qux = 15

def foo(cb):
    qix = 20
    try:
        cb()
    except:
        logger.exception('callback failed')


def bar1():
    baz = 80.5
    logger.info('Hello')


def bar2():
    baz = 890.50
    logger.info('Hello', exc_info=True)


def bar3():
    baz = 600.524
    raise Exception('this is a test exception')


def bar4():
    baz = 52
    assert baz == 90


FNS = [
    bar1,
    bar2,
    bar3,
    bar4
]


for fn in FNS:
    foo(fn)