Coverage for hookee/plugins/request_url_info.py: 100.00%

1 from datetime import datetime

2

3 from hookee.pluginmanager import REQUEST_PLUGIN

4 from hookee.util import PrintUtil

5

6 __author__ = "Alex Laird"

7 __copyright__ = "Copyright 2023, Alex Laird"

8 __version__ = "1.2.2"

9

10 plugin_type = REQUEST_PLUGIN

11 description = "Print the timestamp along with the request URL and method being invoked."

12

13 print_util = None # type: PrintUtil

14

15

16 def setup(hookee_manager):

17 global print_util

18

19 print_util = hookee_manager.print_util

20

21

22 def run(request):

23 now = datetime.now()

24

25 timestamp = now.strftime("%m-%d-%Y %I:%M:%S %p")

26

27 print_util.print_basic("[{}] \"{} {} {}\"".format(timestamp, request.method, request.base_url,

28 request.environ["SERVER_PROTOCOL"]),

29 color=print_util.request_color, bold=True)

30 print_util.print_basic()

31

32 return request