m7mdal7aj commited on
Commit
89070b6
·
verified ·
1 Parent(s): 40cd663

Update my_model/utilities/gen_utilities.py

Browse files
Files changed (1) hide show
  1. my_model/utilities/gen_utilities.py +0 -59
my_model/utilities/gen_utilities.py CHANGED
@@ -8,67 +8,8 @@ from IPython import get_ipython
8
  import sys
9
  import gc
10
  import streamlit as st
11
- import logging
12
- import functools
13
 
14
 
15
- ###### this is used for logging any interaction with the app. ########
16
-
17
- ###### Logging Decorator ########
18
- log_file = 'my_model/utilities/app.log'
19
-
20
- # Set up logging
21
- logging.basicConfig(filename=log_file, level=logging.DEBUG, format='%(asctime)s - %(message)s')
22
-
23
- def log_event(event: str) -> None:
24
- """
25
- Logs an event with the current timestamp.
26
- Args:
27
- event (str): The event description to log.
28
- """
29
- try:
30
- logging.info(event)
31
- except Exception as e:
32
- logging.error(f"Failed to log event: {e}")
33
-
34
- def log_function_call(func):
35
- """
36
- Decorator that logs the function call details (name and arguments).
37
- Args:
38
- func (function): The function to be decorated.
39
- Returns:
40
- function: The wrapped function with logging.
41
- """
42
- @functools.wraps(func)
43
- def wrapper(*args, **kwargs):
44
- log_event(f'Function {func.__name__} called with args: {args} and kwargs: {kwargs}')
45
- result = func(*args, **kwargs)
46
- log_event(f'Function {func.__name__} completed')
47
- return result
48
- return wrapper
49
-
50
- ##### End of Logging Decorator #####
51
-
52
-
53
- # Set up logging
54
- logging.basicConfig(filename='app.log', level=logging.INFO)
55
-
56
- def log_click(widget_name):
57
- logging.info(f'{widget_name} was clicked.')
58
-
59
- import csv
60
- from datetime import datetime
61
-
62
- log_file_path = 'app_log.csv'
63
-
64
- def log_to_csv(event, message):
65
- with open(log_file_path, 'a', newline='') as file:
66
- st.header("GHXDFDGDRHGFTHFGHFGH")
67
- writer = csv.writer(file)
68
- writer.writerow([datetime.now(), event, message])
69
-
70
- ########################
71
-
72
 
73
  def show_image(image):
74
  """
 
8
  import sys
9
  import gc
10
  import streamlit as st
 
 
11
 
12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
  def show_image(image):
15
  """