6.1 Contracts
The Purpose of Contracts
Contracting Contexts
App State :: defines the state of the app through a Bool : context
continue running [True];
this is shutting down: () => not this (continue running).
Log Level :: Int : enum
Verbose[0],
Debug[1],
Warning[2],
Error[3].
Log Settings :: logging settings with Log Level : context
minimum level [Log Level (Debug)].
Log Message :: a String message and a Log Level, to be logged : context
itself, level [Log Level (Debug)].
Console Log Route :: Log Settings : context.
Run App :: create the default App State, initialize and run until shutdown :
behavior {app}?
Initialize :: for {app} when initialized?
activate Log Message ["App Initialized.", Level [Log Level (Debug)] ];
Run :: for {app} whenever app(continue running)?
activate Log Message ["App is running.", Level [Log Level (Verbose)] ],
evaluate Console Response,
activate Log Message ["About to shut down!", Level [Log Level (Warning)] ],
app(continue running) is False;
Shutdown :: for {app}
whenever app is shutting down,
after all?
deactivate app.
Maintain Console Log Route ::
maintain the existence of an optional coexistent Console Log Route in accordance
with shared App State : behavior {route, app}
when app(continue running)?
Log Stop :: when terminated?
activate Log Message ["Stopping Logs.", level [Log Level(Debug)] ].
Perform Route Logging ::
handles logging per a unique Console Log Route for shared {*Log Message*} :
behavior {route, messages}
where messages is messages filtered by
[(message) => message(level) >= route(minimum level)]?
Valid Log Message :: Log Message : context;
Initiate Logging :: for {messages}
whenever |messages| > 0,
foreach message in messages?
evaluate message as Valid Log Message,
deactivate message.
Perform Console Logging [Perform Route Logging] ::
logging per a unique Console Log Route for shared {*Log Message*}:
behavior {route, messages}?
Log :: log a Valid Log Message to the console : <message>?
evaluate "Log: \(message)" as Console Message.Abstracting Behavior Contexts
Last updated