@@ -20,7 +20,7 @@ class AstroLogger(logging.Logger):
20
20
astro_theme : Theme
21
21
progress : AstroProgress
22
22
23
- def astro_config (self , log_level_str : str ):
23
+ def astro_config (self , log_level_str : str , astro_theme ):
24
24
"""
25
25
Custom logging config.
26
26
"""
@@ -29,21 +29,10 @@ def astro_config(self, log_level_str: str):
29
29
30
30
self .setLevel (self .log_level )
31
31
32
- # define astro color theme
33
- self .astro_text_color = 'sky_blue3'
34
- self .astro_theme = Theme ({
35
- "log.message" : self .astro_text_color ,
36
- "logging.level.info" : 'blue_violet' ,
37
- "logging.level.warning" : "orange_red1" ,
38
- "logging.level.error" : "red" ,
39
- "bar.finished" : "green" ,
40
- "progress.elapsed" : self .astro_text_color ,
41
- "progress.remaining" : self .astro_text_color ,
42
- "progress.percentage" : "green" ,
43
- "table.title" : "bold " + self .astro_text_color })
32
+ self .astro_theme = astro_theme
44
33
45
34
# create console using the asto theme
46
- self .console = Console ( theme = self .astro_theme )
35
+ self .console = self .astro_theme . get_console ( )
47
36
48
37
# configure logging
49
38
logging .basicConfig (format = '%(message)s' ,
@@ -52,9 +41,9 @@ def astro_config(self, log_level_str: str):
52
41
console = self .console )])
53
42
54
43
# suppress google logs
55
- self .suppress_logs ('google' , logging .WARNING )
44
+ self .__suppress_logs ('google' , logging .WARNING )
56
45
57
- def suppress_logs (self , name , level ):
46
+ def __suppress_logs (self , name , level ):
58
47
"""
59
48
Suppress logging of external modules.
60
49
"""
@@ -67,7 +56,7 @@ def progress_bar(self, task_str: str, steps: int):
67
56
"""
68
57
Display a progress bar on the console.
69
58
"""
70
- self .progress = AstroProgress (task_str , steps , console = self .console , style = self . astro_text_color )
59
+ self .progress = AstroProgress (task_str , steps , console = self .console )
71
60
return self .progress
72
61
73
62
def get_log_level (self , log_level : str ) -> int :
@@ -87,14 +76,15 @@ def get_log_level(self, log_level: str) -> int:
87
76
88
77
return log_level
89
78
90
- def rich_table (self , title = '' ):
79
+ def __rich_table (self , title = '' ):
91
80
"""
92
81
Create a rich.Table object using the default project theme/style.
93
82
"""
94
- table = Table (style = self .astro_text_color ,
95
- border_style = self .astro_text_color ,
96
- header_style = self .astro_text_color ,
97
- row_styles = [self .astro_text_color ],
83
+ text_color = self .astro_theme .get_style ()
84
+ table = Table (style = text_color ,
85
+ border_style = text_color ,
86
+ header_style = text_color ,
87
+ row_styles = [text_color ],
98
88
title = title )
99
89
100
90
return table
@@ -110,7 +100,7 @@ def print_object(self, obj, title=''):
110
100
if self .log_level > logging .INFO :
111
101
return
112
102
113
- table = self .rich_table (title )
103
+ table = self .__rich_table (title )
114
104
table .add_column ("Attribute" )
115
105
table .add_column ("Value" )
116
106
@@ -130,7 +120,7 @@ def print_dataframe(self, df, title=''):
130
120
# ensure dataframe contains only string values
131
121
df = df .astype (str )
132
122
133
- table = self .rich_table (title )
123
+ table = self .__rich_table (title )
134
124
135
125
# add dataframe columns
136
126
for col in df .columns :
0 commit comments