4.3. foundations.core

core.py

Platform:
Windows, Linux, Mac Os X.
Description:
This module defines Foundations package core objects. Those objects are mostly related to logging and execution tracing.

Others:

4.3.1. Module Attributes

foundations.core.THREADS_IDENTIFIERS
foundations.core.LOGGER
foundations.core.LOGGING_DEFAULT_FORMATTER
foundations.core.LOGGING_EXTENDED_FORMATTER
foundations.core.LOGGING_STANDARD_FORMATTER
foundations.core.IGNORED_CODE_LAYERS
foundations.core.UNDEFINED_CODE_LAYER
foundations.core.UNDEFINED_MODULE
foundations.core.UNDEFINED_OBJECT

4.3.2. Functions

foundations.core.setVerbosityLevel(verbosityLevel)[source]

This definition defines logging verbosity level.

Available verbosity levels:

0: Critical.
1: Error.
2: Warning.
3: Info.
4: Debug.
Parameters:verbosityLevel – Verbosity level. ( Integer )
Returns:Definition success. ( Boolean )
foundations.core.getFrame(index=0)[source]

This definition returns requested execution frame.

Parameters:level – Frame index. ( Integer )
Returns:Frame. ( Frame )
foundations.core.getCodeLayerName()[source]

This definition returns first candidate frame code layer name.

Returns:Code layer name. ( String )
Note :Candidates names matching any foundations.core.IGNORED_CODE_LAYERS members will be skipped. If no appropriate candidate name is found, then foundations.core.UNDEFINED_CODE_LAYER is returned.
foundations.core.getModule(object)[source]

This definition returns given object module name.

Parameters:object – Object. ( Object )
Returns:Frame Module. ( Module )
foundations.core.getTraceName(object)[source]

This definition returns object name composited with current execution frame.

Examples names:

'foundations.environment | getUserApplicationDataDirectory()'.
'__main__ | _setUserApplicationDataDirectory()'.
'__main__ | Preferences.__init__()'.
'UndefinedObject'.
Parameters:object – Object. ( Object )
Returns:Object name. ( String )
foundations.core.extractStack(frame, stackTraceFrameTag='__stackTraceFrameTag__')[source]
This definition extracts the stack from provided frame.
The code is similar to traceback.extract_stack() except that it allows frames to be excluded from the stack if the given stack trace frame tag is found in the frame locals and set True.
Parameters:
  • frame – Frame. ( Frame )
  • stackTraceFrameTag – Stack trace frame tag. ( String )
Returns:

Stack. ( List )

foundations.core.executionTrace(object)[source]
This decorator is used for execution tracing.
Any method / definition decorated will have it’s execution traced through debug messages.
Both object entry and exit are logged.

Entering in an object:

DEBUG   : --->>> 'foundations.environment | getUserApplicationDataDirectory()' <<<---

Exiting from an object:

DEBUG   : --->>> 'foundations.environment | getSystemApplicationDataDirectory()' <<<---
Parameters:object – Object to decorate. ( Object )
Returns:Object. ( Object )
foundations.core.executionTime(object)[source]
This decorator is used for execution timing.
Any method / definition decorated will have it’s execution timed through information messages.
Parameters:object – Object to decorate. ( Object )
Returns:Object. ( Object )
foundations.core.memoize(cache=None)[source]
This decorator is used for method / definition memoization.
Any method / definition decorated will get its return value cached and restored whenever called with the same arguments.
Parameters:cache – Alternate cache. ( Dictionary )
Returns:Object. ( Object )
foundations.core.removeLoggingHandler(logger, handler)[source]

This definition removes given logging handler from given logger.

Parameters:
  • logger – Handler parent logger. ( Logger )
  • handler – Handler. ( Handler )
Returns:

Definition success. ( Boolean )

foundations.core.exit(exitCode=1)[source]

This definition shuts down current process logging, associated handlers and then exits to system.

Parameters:exitCode – System exit code. ( Integer / String / Object )
Note :exitCode argument is passed to Python sys.exit() definition.
foundations.core.wait(waitTime)[source]

This definition halts current process exection for an user defined time.

Parameters:waitTime – Current sleep time in seconds. ( Float )
Returns:Definition success. ( Boolean )

4.3.3. Classes

class foundations.core.StandardMessageHook(logger)[source]

Bases: object

This class is a redirection object intented to be used for sys.stdout and sys.stderr streams.
Logging messages will be written to given logger handlers.
Parameters:logger – Logger. ( Object )
logger[source]

This method is the property for self.__logger attribute.

Returns:self.__logger. ( Logger )
write(message)[source]

This method writes given message to logger handlers.

Parameters:message – Message. ( String )
Returns:Method success. ( Boolean )

Table Of Contents

Previous topic

4.2. foundations.common

Next topic

4.4. foundations.dataStructures

This Page