Skip to content

pfun.logging.Logging

Module providing logging capability

critical(self, msg, stack_info=False, exc_info=False)

Create an effect that calls built-in logging.info

Examples:

>>> Logging().critical('hello!').run(None)
CRITICAL:root:hello!

Parameters:

Name Type Description Default
msg str

the log message

required
stack_info bool

whether to include stack information in the log message

False
exc_info Union[bool, ExcInfo]

whether to include exception info in the log message

False

Returns:

Type Description
Success[None]

Effect that calls logging.critical with msg

debug(self, msg, stack_info=False, exc_info=False)

Create an effect that calls built-in logging.debug

Examples:

>>> Logging().debug('hello!').run(None)
DEBUG:root:hello!

Parameters:

Name Type Description Default
msg str

the log message

required
stack_info bool

whether to include stack information in the log message

False
exc_info Union[bool, ExcInfo]

whether to include exception info in the log message

False

Returns:

Type Description
Success[None]

Effect that calls logging.debug with msg

error(self, msg, stack_info=False, exc_info=False)

Create an effect that calls built-in logging.error

Examples:

>>> Logging().error('hello!').run(None)
ERROR:root:hello!

Parameters:

Name Type Description Default
msg str

the log message

required
stack_info bool

whether to include stack information in the log message

False
exc_info Union[bool, ExcInfo]

whether to include exception info in the log message

False

Returns:

Type Description
Success[None]

Effect that calls logging.error with msg

exception(self, msg, stack_info=True, exc_info=True)

Create an effect that calls built-in logging.exception

Examples:

>>> Logging().exception('hello!').run(None)
ERROR:root:hello!

Parameters:

Name Type Description Default
msg str

the log message

required
stack_info bool

whether to include stack information in the log message

True
exc_info Union[bool, ExcInfo]

whether to include exception info in the log message

True

Returns:

Type Description
Success[None]

Effect that calls logging.exception with msg

get_logger(self, name=None)

Create an effect that produces a Logger by calling built-in logging.getLogger

Examples:

>>> Logging().get_logger('foo').and_then(
...     lambda logger: logger.info('hello!')
... ).run(None)
INFO:foo:hello!

Parameters:

Name Type Description Default
name Optional[str]

name of logger

None

Returns:

Type Description
Logger

Effect that produces a Logger

info(self, msg, stack_info=False, exc_info=False)

Create an effect that calls built-in logging.info

Examples:

>>> Logging().info('hello!').run(None)
INFO:root:hello!

Parameters:

Name Type Description Default
msg str

the log message

required
stack_info bool

whether to include stack information in the log message

False
exc_info Union[bool, ExcInfo]

whether to include exception info in the log message

False

Returns:

Type Description
Success[None]

Effect that calls logging.info with msg

warning(self, msg, stack_info=False, exc_info=False)

Create an effect that calls built-in logging.warning

Examples:

>>> Logging().warning('hello!').run(None)
WARNING:root:hello!

Parameters:

Name Type Description Default
msg str

the log message

required
stack_info bool

whether to include stack information in the log message

False
exc_info Union[bool, ExcInfo]

whether to include exception info in the log message

False

Returns:

Type Description
Success[None]

Effect that calls logging.warning with msg

pfun.logging.HasLogging

Module provider for logging capability

:type logging: Logging :attribute logging: The logging instance

pfun.logging.get_logger(name=None)

Create an effect that produces a Logger by calling built-in logging.getLogger

Examples:

>>> class Env:
...     logging = Logging()
>>> get_logger('foo').and_then(
...     lambda logger: logger.info('hello!')
... ).run(None)
INFO:foo:hello!

Parameters:

Name Type Description Default
name Optional[str]

name of logger

None

Returns:

Type Description
Depends[HasLogging, Logger]

Effect that produces a Logger

pfun.logging.debug(msg, stack_info=False, exc_info=False)

Create an effect that calls built-in logging.debug

Examples:

>>> class Env:
...     logging = Logging()
>>> debug('hello!').run(Env())
DEBUG:root:hello!

Parameters:

Name Type Description Default
msg str

the log message

required
stack_info bool

whether to include stack information in the log message

False
exc_info Union[bool, ExcInfo]

whether to include exception info in the log message

False

Returns:

Type Description
Depends[HasLogging, None]

Effect that calls logging.debug with msg

pfun.logging.info(msg, stack_info=False, exc_info=False)

Create an effect that calls built-in logging.info

Examples:

>>> class Env:
...     logging = Logging()
>>> info('hello!').run(Env())
INFO:root:hello!

Parameters:

Name Type Description Default
msg str

the log message

required
stack_info bool

whether to include stack information in the log message

False
exc_info Union[bool, ExcInfo]

whether to include exception info in the log message

False

Returns:

Type Description
Depends[HasLogging, None]

Effect that calls logging.info with msg

pfun.logging.warning(msg, stack_info=False, exc_info=False)

Create an effect that calls built-in logging.warning

Examples:

>>> class Env:
...     logging = Logging()
>>> warning('hello!').run(Env())
WARNING:root:hello!

Parameters:

Name Type Description Default
msg str

the log message

required
stack_info bool

whether to include stack information in the log message

False
exc_info Union[bool, ExcInfo]

whether to include exception info in the log message

False

Returns:

Type Description
Depends[HasLogging, None]

Effect that calls logging.warning with msg

pfun.logging.error(msg, stack_info=False, exc_info=False)

Create an effect that calls built-in logging.error

Examples:

>>> class Env:
...     logging = Logging()
>>> error('hello!').run(Env())
ERROR:root:hello!

Parameters:

Name Type Description Default
msg str

the log message

required
stack_info bool

whether to include stack information in the log message

False
exc_info Union[bool, ExcInfo]

whether to include exception info in the log message

False

Returns:

Type Description
Depends[HasLogging, None]

Effect that calls logging.error with msg

pfun.logging.exception(msg, stack_info=True, exc_info=True)

Create an effect that calls built-in logging.exception

Examples:

>>> class Env:
...     logging = Logging()
>>> exception('hello!').run(Env())
ERROR:root:hello!

Parameters:

Name Type Description Default
msg str

the log message

required
stack_info bool

whether to include stack information in the log message

True
exc_info Union[bool, ExcInfo]

whether to include exception info in the log message

True

Returns:

Type Description
Depends[HasLogging, None]

Effect that calls logging.exception with msg

pfun.logging.critical(msg, stack_info=False, exc_info=False)

Create an effect that calls built-in logging.critical

Examples:

>>> class Env:
...     logging = Logging()
>>> critical('hello!').run(Env())
CRITICAL:root:hello!

Parameters:

Name Type Description Default
msg str

the log message

required
stack_info bool

whether to include stack information in the log message

False
exc_info Union[bool, ExcInfo]

whether to include exception info in the log message

False

Returns:

Type Description
Depends[HasLogging, None]

Effect that calls logging.critical with msg