Design Pattern Examples
Overview of object-oriented design patterns
bridge_exercise.py
Go to the documentation of this file.
5
6from .bridge_logger import Logger
7
8
17def _Bridge_Exercise_Demonstrate_Logging(logger : Logger, loggerType : str) -> None:
18 logger.LogTrace("Starting log to {0} example".format(loggerType))
19 logger.LogInfo("An example of an informational line")
20 logger.LogError("An example of an error log entry")
21 logger.LogTrace("Done with log to {0} example".format(loggerType))
22
23
24
32
33# ! [Using Bridge in Python]
35 print()
36 print("Bridge Exercise")
37
38 with Logger(Logger.LoggerTypes.ToFile, "Bridge.log") as logger:
39 print(" Example of writing to a log file...")
41
42 with Logger(Logger.LoggerTypes.ToConsole) as logger:
43 print(" Example of writing to the console...")
45
46 with Logger(Logger.LoggerTypes.ToNull) as logger:
47 print(" Example of writing to a Null object (no output)...")
48 # Note: The resulting log lines will not be shown anywhere.
50
51 print(" Done.")
52# ! [Using Bridge in Python]
Represents the bridge logger object to be used in the program.
def Bridge_Exercise()
Example of using the Bridge Pattern.
None _Bridge_Exercise_Demonstrate_Logging(Logger logger, str loggerType)
Helper function to show an example of writing to a logger.