Chenglu-She commited on
Commit
53b081c
1 Parent(s): 8a08281

Upload folder using huggingface_hub

Browse files
README.md CHANGED
@@ -1,9 +1,9 @@
1
 
2
  ---
3
  tags: [gradio-custom-component,gradio-template-SimpleTextbox,log,gradio_log,gradio_log_component,gradio_print_log]
4
- title: gradio_log V0.0.3
5
- colorFrom: green
6
- colorTo: red
7
  sdk: docker
8
  pinned: false
9
  license: apache-2.0
 
1
 
2
  ---
3
  tags: [gradio-custom-component,gradio-template-SimpleTextbox,log,gradio_log,gradio_log_component,gradio_print_log]
4
+ title: gradio_log V0.0.4
5
+ colorFrom: blue
6
+ colorTo: yellow
7
  sdk: docker
8
  pinned: false
9
  license: apache-2.0
__pycache__/__init__.cpython-310.pyc ADDED
Binary file (139 Bytes). View file
 
__pycache__/app.cpython-310.pyc ADDED
Binary file (2.04 kB). View file
 
app.py CHANGED
@@ -1,11 +1,9 @@
1
- from pathlib import Path
2
  import logging
3
- import gradio as gr
4
 
 
5
  from gradio_log import Log
6
 
7
- import logging
8
-
9
 
10
  class CustomFormatter(logging.Formatter):
11
 
@@ -51,7 +49,6 @@ logger.info("The logs will be displayed in here.")
51
 
52
 
53
  def create_log_handler(level):
54
-
55
  def l(text):
56
  getattr(logger, level)(text)
57
 
@@ -64,7 +61,7 @@ with gr.Blocks() as demo:
64
  for l in ["debug", "info", "warning", "error", "critical"]:
65
  button = gr.Button(f"log as {l}")
66
  button.click(fn=create_log_handler(l), inputs=text)
67
- Log(log_file)
68
 
69
 
70
  if __name__ == "__main__":
 
 
1
  import logging
2
+ from pathlib import Path
3
 
4
+ import gradio as gr
5
  from gradio_log import Log
6
 
 
 
7
 
8
  class CustomFormatter(logging.Formatter):
9
 
 
49
 
50
 
51
  def create_log_handler(level):
 
52
  def l(text):
53
  getattr(logger, level)(text)
54
 
 
61
  for l in ["debug", "info", "warning", "error", "critical"]:
62
  button = gr.Button(f"log as {l}")
63
  button.click(fn=create_log_handler(l), inputs=text)
64
+ Log(log_file, dark=True)
65
 
66
 
67
  if __name__ == "__main__":
requirements.txt CHANGED
@@ -1 +1 @@
1
- gradio_log==0.0.2
 
1
+ gradio_log==0.0.3
space.py CHANGED
@@ -3,7 +3,7 @@ import gradio as gr
3
  from app import demo as app
4
  import os
5
 
6
- _docs = {'Log': {'description': 'Create a log component which can continuously read from a log file and display the content in a container.', 'members': {'__init__': {'log_file': {'type': 'str', 'default': 'None', 'description': 'the log file path to read from.'}, 'tail': {'type': 'int', 'default': '100', 'description': 'from the end of the file, the number of lines to start read from.'}, 'dark': {'type': 'bool', 'default': 'False', 'description': 'if True, will render the component in dark mode.'}, 'label': {'type': 'str | None', 'default': 'None', 'description': 'The label for this component. Appears above the component and is also used as the header if there are a table of examples for this component. If None and used in a `gr.Interface`, the label will be the name of the parameter this component is assigned to.'}, 'info': {'type': 'str | None', 'default': 'None', 'description': 'additional component description.'}, 'every': {'type': 'float', 'default': '0.3', 'description': 'New log pulling interval.'}, 'show_label': {'type': 'bool | None', 'default': 'None', 'description': 'if True, will display label.'}, 'container': {'type': 'bool', 'default': 'True', 'description': 'If True, will place the component in a container - providing some extra padding around the border.'}, 'scale': {'type': 'int | None', 'default': 'None', 'description': 'relative size compared to adjacent Components. For example if Components A and B are in a Row, and A has scale=2, and B has scale=1, A will be twice as wide as B. Should be an integer. scale applies in Rows, and to top-level Components in Blocks where fill_height=True.'}, 'min_width': {'type': 'int', 'default': '160', 'description': 'minimum pixel width, will wrap if not sufficient screen space to satisfy this value. If a certain scale value results in this Component being narrower than min_width, the min_width parameter will be respected first.'}, 'interactive': {'type': 'bool | None', 'default': 'None', 'description': 'if True, will be rendered as an editable textbox; if False, editing will be disabled. If not provided, this is inferred based on whether the component is used as an input or output.'}, 'visible': {'type': 'bool', 'default': 'True', 'description': 'If False, component will be hidden.'}, 'elem_id': {'type': 'str | None', 'default': 'None', 'description': 'An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.'}, 'elem_classes': {'type': 'list[str] | str | None', 'default': 'None', 'description': 'An optional list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.'}, 'render': {'type': 'bool', 'default': 'True', 'description': 'If False, component will not render be rendered in the Blocks context. Should be used if the intention is to assign event listeners now but render the component later.'}}, 'postprocess': {}, 'preprocess': {'return': {'type': 'typing.Any', 'description': "The preprocessed input data sent to the user's function in the backend."}, 'value': None}}, 'events': {'load': {'type': None, 'default': None, 'description': 'This listener is triggered when the Log initially loads in the browser.'}}}, '__meta__': {'additional_interfaces': {}, 'user_fn_refs': {'Log': []}}}
7
 
8
  abs_path = os.path.join(os.path.dirname(__file__), "css.css")
9
 
@@ -38,14 +38,12 @@ pip install gradio_log
38
  ## Usage
39
 
40
  ```python
41
- from pathlib import Path
42
  import logging
43
- import gradio as gr
44
 
 
45
  from gradio_log import Log
46
 
47
- import logging
48
-
49
 
50
  class CustomFormatter(logging.Formatter):
51
 
@@ -91,7 +89,6 @@ logger.info("The logs will be displayed in here.")
91
 
92
 
93
  def create_log_handler(level):
94
-
95
  def l(text):
96
  getattr(logger, level)(text)
97
 
@@ -104,7 +101,7 @@ with gr.Blocks() as demo:
104
  for l in ["debug", "info", "warning", "error", "critical"]:
105
  button = gr.Button(f"log as {l}")
106
  button.click(fn=create_log_handler(l), inputs=text)
107
- Log(log_file)
108
 
109
 
110
  if __name__ == "__main__":
@@ -145,7 +142,7 @@ The code snippet below is accurate in cases where the component is used as both
145
 
146
  ```python
147
  def predict(
148
- value: typing.Any
149
  ) -> Unknown:
150
  return value
151
  ```
 
3
  from app import demo as app
4
  import os
5
 
6
+ _docs = {'Log': {'description': 'Create a log component which can continuously read from a log file and display the content in a container.', 'members': {'__init__': {'log_file': {'type': 'str', 'default': 'None', 'description': 'the log file path to read from.'}, 'tail': {'type': 'int', 'default': '100', 'description': 'from the end of the file, the number of lines to start read from.'}, 'dark': {'type': 'bool', 'default': 'False', 'description': 'if True, will render the component in dark mode.'}, 'xterm_allow_proposed_api': {'type': 'bool | None', 'default': 'False', 'description': None}, 'xterm_allow_transparency': {'type': 'bool | None', 'default': 'False', 'description': None}, 'xterm_alt_click_moves_cursor': {'type': 'bool | None', 'default': 'True', 'description': None}, 'xterm_convert_eol': {'type': 'bool | None', 'default': 'False', 'description': None}, 'xterm_cursor_blink': {'type': 'bool | None', 'default': 'False', 'description': None}, 'xterm_cursor_inactive_style': {'type': '"outline" | "block" | "bar" | "underline" | "none"', 'default': '"outline"', 'description': None}, 'xterm_cursor_style': {'type': '"block" | "underline" | "bar"', 'default': '"block"', 'description': None}, 'xterm_cursor_width': {'type': 'int | None', 'default': '1', 'description': None}, 'xterm_custom_glyphs': {'type': 'bool | None', 'default': 'False', 'description': None}, 'xterm_disable_stdin': {'type': 'bool | None', 'default': 'True', 'description': None}, 'xterm_document_override': {'type': 'Any | None', 'default': 'None', 'description': None}, 'xterm_draw_bold_text_in_bright_colors': {'type': 'bool | None', 'default': 'True', 'description': None}, 'xterm_fast_scroll_modifier': {'type': '"none" | "alt" | "ctrl" | "shift" | None', 'default': '"alt"', 'description': None}, 'xterm_fast_scroll_sensitivity': {'type': 'int | None', 'default': '1', 'description': None}, 'xterm_font_family': {'type': 'str | None', 'default': '"courier-new, courier, monospace"', 'description': None}, 'xterm_font_size': {'type': 'int | None', 'default': '15', 'description': None}, 'xterm_font_weight': {'type': '"normal"\n | "bold"\n | "100"\n | "200"\n | "300"\n | "400"\n | "500"\n | "600"\n | "700"\n | "800"\n | "900"\n | None', 'default': '"normal"', 'description': None}, 'xterm_font_weight_bold': {'type': '"normal"\n | "bold"\n | "100"\n | "200"\n | "300"\n | "400"\n | "500"\n | "600"\n | "700"\n | "800"\n | "900"\n | None', 'default': '"bold"', 'description': None}, 'xterm_ignore_bracketed_paste_mode': {'type': 'bool | None', 'default': 'False', 'description': None}, 'xterm_letter_spacing': {'type': 'float | None', 'default': '0', 'description': None}, 'xterm_line_height': {'type': 'float | None', 'default': '1.0', 'description': None}, 'xterm_log_level': {'type': '"trace" | "debug" | "info" | "warn" | "error" | "off" | None', 'default': '"info"', 'description': None}, 'xterm_mac_option_click_forces_selection': {'type': 'bool | None', 'default': 'False', 'description': None}, 'xterm_mac_option_is_meta': {'type': 'bool | None', 'default': 'False', 'description': None}, 'xterm_minimum_contrast_ratio': {'type': 'int | None', 'default': '1', 'description': None}, 'xterm_overview_ruler_width': {'type': 'int | None', 'default': '0', 'description': None}, 'xterm_rescale_overlapping_glyphs': {'type': 'bool | None', 'default': 'False', 'description': None}, 'xterm_screen_reader_mode': {'type': 'bool | None', 'default': 'False', 'description': None}, 'xterm_scroll_on_user_input': {'type': 'bool | None', 'default': 'True', 'description': None}, 'xterm_scroll_sensitivity': {'type': 'int | None', 'default': '1', 'description': None}, 'xterm_scrollback': {'type': 'int | None', 'default': '1000', 'description': None}, 'xterm_smooth_scroll_duration': {'type': 'int | None', 'default': '0', 'description': None}, 'xterm_tab_stop_width': {'type': 'int | None', 'default': '8', 'description': None}, 'xterm_windows_mode': {'type': 'bool | None', 'default': 'False', 'description': None}, 'label': {'type': 'str | None', 'default': 'None', 'description': 'The label for this component. Appears above the component and is also used as the header if there are a table of examples for this component. If None and used in a `gr.Interface`, the label will be the name of the parameter this component is assigned to.'}, 'info': {'type': 'str | None', 'default': 'None', 'description': 'additional component description.'}, 'every': {'type': 'float', 'default': '0.3', 'description': 'New log pulling interval.'}, 'show_label': {'type': 'bool | None', 'default': 'None', 'description': 'if True, will display label.'}, 'container': {'type': 'bool', 'default': 'True', 'description': 'If True, will place the component in a container - providing some extra padding around the border.'}, 'scale': {'type': 'int | None', 'default': 'None', 'description': 'relative size compared to adjacent Components. For example if Components A and B are in a Row, and A has scale=2, and B has scale=1, A will be twice as wide as B. Should be an integer. scale applies in Rows, and to top-level Components in Blocks where fill_height=True.'}, 'min_width': {'type': 'int', 'default': '160', 'description': 'minimum pixel width, will wrap if not sufficient screen space to satisfy this value. If a certain scale value results in this Component being narrower than min_width, the min_width parameter will be respected first.'}, 'interactive': {'type': 'bool | None', 'default': 'None', 'description': 'if True, will be rendered as an editable textbox; if False, editing will be disabled. If not provided, this is inferred based on whether the component is used as an input or output.'}, 'visible': {'type': 'bool', 'default': 'True', 'description': 'If False, component will be hidden.'}, 'elem_id': {'type': 'str | None', 'default': 'None', 'description': 'An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.'}, 'elem_classes': {'type': 'list[str] | str | None', 'default': 'None', 'description': 'An optional list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.'}, 'render': {'type': 'bool', 'default': 'True', 'description': 'If False, component will not render be rendered in the Blocks context. Should be used if the intention is to assign event listeners now but render the component later.'}}, 'postprocess': {}, 'preprocess': {'return': {'type': 'Any', 'description': "The preprocessed input data sent to the user's function in the backend."}, 'value': None}}, 'events': {'load': {'type': None, 'default': None, 'description': 'This listener is triggered when the Log initially loads in the browser.'}}}, '__meta__': {'additional_interfaces': {}, 'user_fn_refs': {'Log': []}}}
7
 
8
  abs_path = os.path.join(os.path.dirname(__file__), "css.css")
9
 
 
38
  ## Usage
39
 
40
  ```python
 
41
  import logging
42
+ from pathlib import Path
43
 
44
+ import gradio as gr
45
  from gradio_log import Log
46
 
 
 
47
 
48
  class CustomFormatter(logging.Formatter):
49
 
 
89
 
90
 
91
  def create_log_handler(level):
 
92
  def l(text):
93
  getattr(logger, level)(text)
94
 
 
101
  for l in ["debug", "info", "warning", "error", "critical"]:
102
  button = gr.Button(f"log as {l}")
103
  button.click(fn=create_log_handler(l), inputs=text)
104
+ Log(log_file, dark=True)
105
 
106
 
107
  if __name__ == "__main__":
 
142
 
143
  ```python
144
  def predict(
145
+ value: Any
146
  ) -> Unknown:
147
  return value
148
  ```
src/.DS_Store ADDED
Binary file (6.15 kB). View file
 
src/.gitignore CHANGED
@@ -7,4 +7,5 @@ __pycache__/
7
  __tmp/*
8
  *.pyi
9
  node_modules
10
- test.log
 
 
7
  __tmp/*
8
  *.pyi
9
  node_modules
10
+ test.log
11
+ .DS_Store
src/README.md CHANGED
@@ -13,14 +13,12 @@ pip install gradio_log
13
  ## Usage
14
 
15
  ```python
16
- from pathlib import Path
17
  import logging
18
- import gradio as gr
19
 
 
20
  from gradio_log import Log
21
 
22
- import logging
23
-
24
 
25
  class CustomFormatter(logging.Formatter):
26
 
@@ -66,7 +64,6 @@ logger.info("The logs will be displayed in here.")
66
 
67
 
68
  def create_log_handler(level):
69
-
70
  def l(text):
71
  getattr(logger, level)(text)
72
 
@@ -79,7 +76,7 @@ with gr.Blocks() as demo:
79
  for l in ["debug", "info", "warning", "error", "critical"]:
80
  button = gr.Button(f"log as {l}")
81
  button.click(fn=create_log_handler(l), inputs=text)
82
- Log(log_file)
83
 
84
 
85
  if __name__ == "__main__":
@@ -140,6 +137,470 @@ bool
140
  <td align="left">if True, will render the component in dark mode.</td>
141
  </tr>
142
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
143
  <tr>
144
  <td align="left"><code>label</code></td>
145
  <td align="left" style="width: 25%;">
@@ -320,7 +781,7 @@ The code snippet below is accurate in cases where the component is used as both
320
 
321
  ```python
322
  def predict(
323
- value: typing.Any
324
  ) -> Unknown:
325
  return value
326
  ```
 
13
  ## Usage
14
 
15
  ```python
 
16
  import logging
17
+ from pathlib import Path
18
 
19
+ import gradio as gr
20
  from gradio_log import Log
21
 
 
 
22
 
23
  class CustomFormatter(logging.Formatter):
24
 
 
64
 
65
 
66
  def create_log_handler(level):
 
67
  def l(text):
68
  getattr(logger, level)(text)
69
 
 
76
  for l in ["debug", "info", "warning", "error", "critical"]:
77
  button = gr.Button(f"log as {l}")
78
  button.click(fn=create_log_handler(l), inputs=text)
79
+ Log(log_file, dark=True)
80
 
81
 
82
  if __name__ == "__main__":
 
137
  <td align="left">if True, will render the component in dark mode.</td>
138
  </tr>
139
 
140
+ <tr>
141
+ <td align="left"><code>xterm_allow_proposed_api</code></td>
142
+ <td align="left" style="width: 25%;">
143
+
144
+ ```python
145
+ bool | None
146
+ ```
147
+
148
+ </td>
149
+ <td align="left"><code>False</code></td>
150
+ <td align="left">None</td>
151
+ </tr>
152
+
153
+ <tr>
154
+ <td align="left"><code>xterm_allow_transparency</code></td>
155
+ <td align="left" style="width: 25%;">
156
+
157
+ ```python
158
+ bool | None
159
+ ```
160
+
161
+ </td>
162
+ <td align="left"><code>False</code></td>
163
+ <td align="left">None</td>
164
+ </tr>
165
+
166
+ <tr>
167
+ <td align="left"><code>xterm_alt_click_moves_cursor</code></td>
168
+ <td align="left" style="width: 25%;">
169
+
170
+ ```python
171
+ bool | None
172
+ ```
173
+
174
+ </td>
175
+ <td align="left"><code>True</code></td>
176
+ <td align="left">None</td>
177
+ </tr>
178
+
179
+ <tr>
180
+ <td align="left"><code>xterm_convert_eol</code></td>
181
+ <td align="left" style="width: 25%;">
182
+
183
+ ```python
184
+ bool | None
185
+ ```
186
+
187
+ </td>
188
+ <td align="left"><code>False</code></td>
189
+ <td align="left">None</td>
190
+ </tr>
191
+
192
+ <tr>
193
+ <td align="left"><code>xterm_cursor_blink</code></td>
194
+ <td align="left" style="width: 25%;">
195
+
196
+ ```python
197
+ bool | None
198
+ ```
199
+
200
+ </td>
201
+ <td align="left"><code>False</code></td>
202
+ <td align="left">None</td>
203
+ </tr>
204
+
205
+ <tr>
206
+ <td align="left"><code>xterm_cursor_inactive_style</code></td>
207
+ <td align="left" style="width: 25%;">
208
+
209
+ ```python
210
+ "outline" | "block" | "bar" | "underline" | "none"
211
+ ```
212
+
213
+ </td>
214
+ <td align="left"><code>"outline"</code></td>
215
+ <td align="left">None</td>
216
+ </tr>
217
+
218
+ <tr>
219
+ <td align="left"><code>xterm_cursor_style</code></td>
220
+ <td align="left" style="width: 25%;">
221
+
222
+ ```python
223
+ "block" | "underline" | "bar"
224
+ ```
225
+
226
+ </td>
227
+ <td align="left"><code>"block"</code></td>
228
+ <td align="left">None</td>
229
+ </tr>
230
+
231
+ <tr>
232
+ <td align="left"><code>xterm_cursor_width</code></td>
233
+ <td align="left" style="width: 25%;">
234
+
235
+ ```python
236
+ int | None
237
+ ```
238
+
239
+ </td>
240
+ <td align="left"><code>1</code></td>
241
+ <td align="left">None</td>
242
+ </tr>
243
+
244
+ <tr>
245
+ <td align="left"><code>xterm_custom_glyphs</code></td>
246
+ <td align="left" style="width: 25%;">
247
+
248
+ ```python
249
+ bool | None
250
+ ```
251
+
252
+ </td>
253
+ <td align="left"><code>False</code></td>
254
+ <td align="left">None</td>
255
+ </tr>
256
+
257
+ <tr>
258
+ <td align="left"><code>xterm_disable_stdin</code></td>
259
+ <td align="left" style="width: 25%;">
260
+
261
+ ```python
262
+ bool | None
263
+ ```
264
+
265
+ </td>
266
+ <td align="left"><code>True</code></td>
267
+ <td align="left">None</td>
268
+ </tr>
269
+
270
+ <tr>
271
+ <td align="left"><code>xterm_document_override</code></td>
272
+ <td align="left" style="width: 25%;">
273
+
274
+ ```python
275
+ Any | None
276
+ ```
277
+
278
+ </td>
279
+ <td align="left"><code>None</code></td>
280
+ <td align="left">None</td>
281
+ </tr>
282
+
283
+ <tr>
284
+ <td align="left"><code>xterm_draw_bold_text_in_bright_colors</code></td>
285
+ <td align="left" style="width: 25%;">
286
+
287
+ ```python
288
+ bool | None
289
+ ```
290
+
291
+ </td>
292
+ <td align="left"><code>True</code></td>
293
+ <td align="left">None</td>
294
+ </tr>
295
+
296
+ <tr>
297
+ <td align="left"><code>xterm_fast_scroll_modifier</code></td>
298
+ <td align="left" style="width: 25%;">
299
+
300
+ ```python
301
+ "none" | "alt" | "ctrl" | "shift" | None
302
+ ```
303
+
304
+ </td>
305
+ <td align="left"><code>"alt"</code></td>
306
+ <td align="left">None</td>
307
+ </tr>
308
+
309
+ <tr>
310
+ <td align="left"><code>xterm_fast_scroll_sensitivity</code></td>
311
+ <td align="left" style="width: 25%;">
312
+
313
+ ```python
314
+ int | None
315
+ ```
316
+
317
+ </td>
318
+ <td align="left"><code>1</code></td>
319
+ <td align="left">None</td>
320
+ </tr>
321
+
322
+ <tr>
323
+ <td align="left"><code>xterm_font_family</code></td>
324
+ <td align="left" style="width: 25%;">
325
+
326
+ ```python
327
+ str | None
328
+ ```
329
+
330
+ </td>
331
+ <td align="left"><code>"courier-new, courier, monospace"</code></td>
332
+ <td align="left">None</td>
333
+ </tr>
334
+
335
+ <tr>
336
+ <td align="left"><code>xterm_font_size</code></td>
337
+ <td align="left" style="width: 25%;">
338
+
339
+ ```python
340
+ int | None
341
+ ```
342
+
343
+ </td>
344
+ <td align="left"><code>15</code></td>
345
+ <td align="left">None</td>
346
+ </tr>
347
+
348
+ <tr>
349
+ <td align="left"><code>xterm_font_weight</code></td>
350
+ <td align="left" style="width: 25%;">
351
+
352
+ ```python
353
+ "normal"
354
+ | "bold"
355
+ | "100"
356
+ | "200"
357
+ | "300"
358
+ | "400"
359
+ | "500"
360
+ | "600"
361
+ | "700"
362
+ | "800"
363
+ | "900"
364
+ | None
365
+ ```
366
+
367
+ </td>
368
+ <td align="left"><code>"normal"</code></td>
369
+ <td align="left">None</td>
370
+ </tr>
371
+
372
+ <tr>
373
+ <td align="left"><code>xterm_font_weight_bold</code></td>
374
+ <td align="left" style="width: 25%;">
375
+
376
+ ```python
377
+ "normal"
378
+ | "bold"
379
+ | "100"
380
+ | "200"
381
+ | "300"
382
+ | "400"
383
+ | "500"
384
+ | "600"
385
+ | "700"
386
+ | "800"
387
+ | "900"
388
+ | None
389
+ ```
390
+
391
+ </td>
392
+ <td align="left"><code>"bold"</code></td>
393
+ <td align="left">None</td>
394
+ </tr>
395
+
396
+ <tr>
397
+ <td align="left"><code>xterm_ignore_bracketed_paste_mode</code></td>
398
+ <td align="left" style="width: 25%;">
399
+
400
+ ```python
401
+ bool | None
402
+ ```
403
+
404
+ </td>
405
+ <td align="left"><code>False</code></td>
406
+ <td align="left">None</td>
407
+ </tr>
408
+
409
+ <tr>
410
+ <td align="left"><code>xterm_letter_spacing</code></td>
411
+ <td align="left" style="width: 25%;">
412
+
413
+ ```python
414
+ float | None
415
+ ```
416
+
417
+ </td>
418
+ <td align="left"><code>0</code></td>
419
+ <td align="left">None</td>
420
+ </tr>
421
+
422
+ <tr>
423
+ <td align="left"><code>xterm_line_height</code></td>
424
+ <td align="left" style="width: 25%;">
425
+
426
+ ```python
427
+ float | None
428
+ ```
429
+
430
+ </td>
431
+ <td align="left"><code>1.0</code></td>
432
+ <td align="left">None</td>
433
+ </tr>
434
+
435
+ <tr>
436
+ <td align="left"><code>xterm_log_level</code></td>
437
+ <td align="left" style="width: 25%;">
438
+
439
+ ```python
440
+ "trace" | "debug" | "info" | "warn" | "error" | "off" | None
441
+ ```
442
+
443
+ </td>
444
+ <td align="left"><code>"info"</code></td>
445
+ <td align="left">None</td>
446
+ </tr>
447
+
448
+ <tr>
449
+ <td align="left"><code>xterm_mac_option_click_forces_selection</code></td>
450
+ <td align="left" style="width: 25%;">
451
+
452
+ ```python
453
+ bool | None
454
+ ```
455
+
456
+ </td>
457
+ <td align="left"><code>False</code></td>
458
+ <td align="left">None</td>
459
+ </tr>
460
+
461
+ <tr>
462
+ <td align="left"><code>xterm_mac_option_is_meta</code></td>
463
+ <td align="left" style="width: 25%;">
464
+
465
+ ```python
466
+ bool | None
467
+ ```
468
+
469
+ </td>
470
+ <td align="left"><code>False</code></td>
471
+ <td align="left">None</td>
472
+ </tr>
473
+
474
+ <tr>
475
+ <td align="left"><code>xterm_minimum_contrast_ratio</code></td>
476
+ <td align="left" style="width: 25%;">
477
+
478
+ ```python
479
+ int | None
480
+ ```
481
+
482
+ </td>
483
+ <td align="left"><code>1</code></td>
484
+ <td align="left">None</td>
485
+ </tr>
486
+
487
+ <tr>
488
+ <td align="left"><code>xterm_overview_ruler_width</code></td>
489
+ <td align="left" style="width: 25%;">
490
+
491
+ ```python
492
+ int | None
493
+ ```
494
+
495
+ </td>
496
+ <td align="left"><code>0</code></td>
497
+ <td align="left">None</td>
498
+ </tr>
499
+
500
+ <tr>
501
+ <td align="left"><code>xterm_rescale_overlapping_glyphs</code></td>
502
+ <td align="left" style="width: 25%;">
503
+
504
+ ```python
505
+ bool | None
506
+ ```
507
+
508
+ </td>
509
+ <td align="left"><code>False</code></td>
510
+ <td align="left">None</td>
511
+ </tr>
512
+
513
+ <tr>
514
+ <td align="left"><code>xterm_screen_reader_mode</code></td>
515
+ <td align="left" style="width: 25%;">
516
+
517
+ ```python
518
+ bool | None
519
+ ```
520
+
521
+ </td>
522
+ <td align="left"><code>False</code></td>
523
+ <td align="left">None</td>
524
+ </tr>
525
+
526
+ <tr>
527
+ <td align="left"><code>xterm_scroll_on_user_input</code></td>
528
+ <td align="left" style="width: 25%;">
529
+
530
+ ```python
531
+ bool | None
532
+ ```
533
+
534
+ </td>
535
+ <td align="left"><code>True</code></td>
536
+ <td align="left">None</td>
537
+ </tr>
538
+
539
+ <tr>
540
+ <td align="left"><code>xterm_scroll_sensitivity</code></td>
541
+ <td align="left" style="width: 25%;">
542
+
543
+ ```python
544
+ int | None
545
+ ```
546
+
547
+ </td>
548
+ <td align="left"><code>1</code></td>
549
+ <td align="left">None</td>
550
+ </tr>
551
+
552
+ <tr>
553
+ <td align="left"><code>xterm_scrollback</code></td>
554
+ <td align="left" style="width: 25%;">
555
+
556
+ ```python
557
+ int | None
558
+ ```
559
+
560
+ </td>
561
+ <td align="left"><code>1000</code></td>
562
+ <td align="left">None</td>
563
+ </tr>
564
+
565
+ <tr>
566
+ <td align="left"><code>xterm_smooth_scroll_duration</code></td>
567
+ <td align="left" style="width: 25%;">
568
+
569
+ ```python
570
+ int | None
571
+ ```
572
+
573
+ </td>
574
+ <td align="left"><code>0</code></td>
575
+ <td align="left">None</td>
576
+ </tr>
577
+
578
+ <tr>
579
+ <td align="left"><code>xterm_tab_stop_width</code></td>
580
+ <td align="left" style="width: 25%;">
581
+
582
+ ```python
583
+ int | None
584
+ ```
585
+
586
+ </td>
587
+ <td align="left"><code>8</code></td>
588
+ <td align="left">None</td>
589
+ </tr>
590
+
591
+ <tr>
592
+ <td align="left"><code>xterm_windows_mode</code></td>
593
+ <td align="left" style="width: 25%;">
594
+
595
+ ```python
596
+ bool | None
597
+ ```
598
+
599
+ </td>
600
+ <td align="left"><code>False</code></td>
601
+ <td align="left">None</td>
602
+ </tr>
603
+
604
  <tr>
605
  <td align="left"><code>label</code></td>
606
  <td align="left" style="width: 25%;">
 
781
 
782
  ```python
783
  def predict(
784
+ value: Any
785
  ) -> Unknown:
786
  return value
787
  ```
src/backend/gradio_log/log.py CHANGED
@@ -3,12 +3,28 @@
3
  from __future__ import annotations
4
 
5
  import time
6
- from typing import Any
7
 
8
  from gradio.components.base import FormComponent
9
  from gradio.events import Events
10
  from gradio_client.documentation import document
11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
 
13
  @document()
14
  class Log(FormComponent):
@@ -53,6 +69,44 @@ class Log(FormComponent):
53
  log_file: str = None,
54
  tail: int = 100,
55
  dark: bool = False,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  *,
57
  label: str | None = None,
58
  info: str | None = None,
@@ -68,6 +122,9 @@ class Log(FormComponent):
68
  render: bool = True,
69
  ):
70
  """
 
 
 
71
  Parameters:
72
  log_file: the log file path to read from.
73
  tail: from the end of the file, the number of lines to start read from.
@@ -92,6 +149,45 @@ class Log(FormComponent):
92
  self.fd = None
93
  self.stop_reading = False
94
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
  super().__init__(
96
  label=label,
97
  info=info,
@@ -122,7 +218,7 @@ class Log(FormComponent):
122
  return {"type": "string"}
123
 
124
  def example_payload(self) -> Any:
125
- return "Hello!!"
126
 
127
  def example_value(self) -> Any:
128
- return "Hello!!"
 
3
  from __future__ import annotations
4
 
5
  import time
6
+ from typing import Any, Literal, Optional
7
 
8
  from gradio.components.base import FormComponent
9
  from gradio.events import Events
10
  from gradio_client.documentation import document
11
 
12
+ FontWeight = Literal[
13
+ "normal",
14
+ "bold",
15
+ "100",
16
+ "200",
17
+ "300",
18
+ "400",
19
+ "500",
20
+ "600",
21
+ "700",
22
+ "800",
23
+ "900",
24
+ ]
25
+
26
+ LogLevel = Literal["trace", "debug", "info", "warn", "error", "off"]
27
+
28
 
29
  @document()
30
  class Log(FormComponent):
 
69
  log_file: str = None,
70
  tail: int = 100,
71
  dark: bool = False,
72
+ xterm_allow_proposed_api: Optional[bool] = False,
73
+ xterm_allow_transparency: Optional[bool] = False,
74
+ xterm_alt_click_moves_cursor: Optional[bool] = True,
75
+ xterm_convert_eol: Optional[bool] = False,
76
+ xterm_cursor_blink: Optional[bool] = False,
77
+ xterm_cursor_inactive_style: Literal[
78
+ "outline", "block", "bar", "underline", "none"
79
+ ] = "outline",
80
+ xterm_cursor_style: Literal["block", "underline", "bar"] = "block",
81
+ xterm_cursor_width: Optional[int] = 1,
82
+ xterm_custom_glyphs: Optional[bool] = False,
83
+ xterm_disable_stdin: Optional[bool] = True,
84
+ xterm_document_override: Optional[Any] = None,
85
+ xterm_draw_bold_text_in_bright_colors: Optional[bool] = True,
86
+ xterm_fast_scroll_modifier: Optional[
87
+ Literal["none", "alt", "ctrl", "shift"]
88
+ ] = "alt",
89
+ xterm_fast_scroll_sensitivity: Optional[int] = 1,
90
+ xterm_font_family: Optional[str] = "courier-new, courier, monospace",
91
+ xterm_font_size: Optional[int] = 15,
92
+ xterm_font_weight: Optional[FontWeight] = "normal",
93
+ xterm_font_weight_bold: Optional[FontWeight] = "bold",
94
+ xterm_ignore_bracketed_paste_mode: Optional[bool] = False,
95
+ xterm_letter_spacing: Optional[float] = 0,
96
+ xterm_line_height: Optional[float] = 1.0,
97
+ xterm_log_level: Optional[LogLevel] = "info",
98
+ xterm_mac_option_click_forces_selection: Optional[bool] = False,
99
+ xterm_mac_option_is_meta: Optional[bool] = False,
100
+ xterm_minimum_contrast_ratio: Optional[int] = 1,
101
+ xterm_overview_ruler_width: Optional[int] = 0,
102
+ xterm_rescale_overlapping_glyphs: Optional[bool] = False,
103
+ xterm_screen_reader_mode: Optional[bool] = False,
104
+ xterm_scroll_on_user_input: Optional[bool] = True,
105
+ xterm_scroll_sensitivity: Optional[int] = 1,
106
+ xterm_scrollback: Optional[int] = 1000,
107
+ xterm_smooth_scroll_duration: Optional[int] = 0,
108
+ xterm_tab_stop_width: Optional[int] = 8,
109
+ xterm_windows_mode: Optional[bool] = False,
110
  *,
111
  label: str | None = None,
112
  info: str | None = None,
 
122
  render: bool = True,
123
  ):
124
  """
125
+ For all the xterm options, please refer to the xterm.js documentation:
126
+ https://xtermjs.org/docs/api/terminal/interfaces/iterminaloptions/
127
+
128
  Parameters:
129
  log_file: the log file path to read from.
130
  tail: from the end of the file, the number of lines to start read from.
 
149
  self.fd = None
150
  self.stop_reading = False
151
 
152
+ self.xterm_allow_proposed_api = xterm_allow_proposed_api
153
+ self.xterm_allow_transparency = xterm_allow_transparency
154
+ self.xterm_alt_click_moves_cursor = xterm_alt_click_moves_cursor
155
+ self.xterm_convert_eol = xterm_convert_eol
156
+ self.xterm_cursor_blink = xterm_cursor_blink
157
+ self.xterm_cursor_inactive_style = xterm_cursor_inactive_style
158
+ self.xterm_cursor_style = xterm_cursor_style
159
+ self.xterm_cursor_width = xterm_cursor_width
160
+ self.xterm_custom_glyphs = xterm_custom_glyphs
161
+ self.xterm_disable_stdin = xterm_disable_stdin
162
+ self.xterm_document_override = xterm_document_override
163
+ self.xterm_draw_bold_text_in_bright_colors = (
164
+ xterm_draw_bold_text_in_bright_colors
165
+ )
166
+ self.xterm_fast_scroll_modifier = xterm_fast_scroll_modifier
167
+ self.xterm_fast_scroll_sensitivity = xterm_fast_scroll_sensitivity
168
+ self.xterm_font_family = xterm_font_family
169
+ self.xterm_font_size = xterm_font_size
170
+ self.xterm_font_weight = xterm_font_weight
171
+ self.xterm_font_weight_bold = xterm_font_weight_bold
172
+ self.xterm_ignore_bracketed_paste_mode = xterm_ignore_bracketed_paste_mode
173
+ self.xterm_letter_spacing = xterm_letter_spacing
174
+ self.xterm_line_height = xterm_line_height
175
+ self.xterm_log_level = xterm_log_level
176
+ self.xterm_mac_option_click_forces_selection = (
177
+ xterm_mac_option_click_forces_selection
178
+ )
179
+ self.xterm_mac_option_is_meta = xterm_mac_option_is_meta
180
+ self.xterm_minimum_contrast_ratio = xterm_minimum_contrast_ratio
181
+ self.xterm_overview_ruler_width = xterm_overview_ruler_width
182
+ self.xterm_rescale_overlapping_glyphs = xterm_rescale_overlapping_glyphs
183
+ self.xterm_screen_reader_mode = xterm_screen_reader_mode
184
+ self.xterm_scroll_on_user_input = xterm_scroll_on_user_input
185
+ self.xterm_scroll_sensitivity = xterm_scroll_sensitivity
186
+ self.xterm_scrollback = xterm_scrollback
187
+ self.xterm_smooth_scroll_duration = xterm_smooth_scroll_duration
188
+ self.xterm_tab_stop_width = xterm_tab_stop_width
189
+ self.xterm_windows_mode = xterm_windows_mode
190
+
191
  super().__init__(
192
  label=label,
193
  info=info,
 
218
  return {"type": "string"}
219
 
220
  def example_payload(self) -> Any:
221
+ pass
222
 
223
  def example_value(self) -> Any:
224
+ pass
src/backend/gradio_log/log.pyi CHANGED
@@ -5,7 +5,6 @@ from typing import Any, Callable
5
  from gradio.components.base import FormComponent
6
  from gradio.events import Events
7
 
8
-
9
  class log(FormComponent):
10
 
11
  def find_start_position(self) -> int:
@@ -169,6 +168,44 @@ class Log(FormComponent):
169
  log_file: str = None,
170
  tail: int = 100,
171
  dark: bool = False,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
172
  *,
173
  label: str | None = None,
174
  info: str | None = None,
@@ -184,6 +221,9 @@ class Log(FormComponent):
184
  render: bool = True,
185
  ):
186
  """
 
 
 
187
  Parameters:
188
  log_file: the log file path to read from.
189
  tail: from the end of the file, the number of lines to start read from.
@@ -208,6 +248,45 @@ class Log(FormComponent):
208
  self.fd = None
209
  self.stop_reading = False
210
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
211
  super().__init__(
212
  label=label,
213
  info=info,
@@ -238,10 +317,10 @@ class Log(FormComponent):
238
  return {"type": "string"}
239
 
240
  def example_payload(self) -> Any:
241
- return "Hello!!"
242
 
243
  def example_value(self) -> Any:
244
- return "Hello!!"
245
 
246
 
247
  def load(self,
 
5
  from gradio.components.base import FormComponent
6
  from gradio.events import Events
7
 
 
8
  class log(FormComponent):
9
 
10
  def find_start_position(self) -> int:
 
168
  log_file: str = None,
169
  tail: int = 100,
170
  dark: bool = False,
171
+ xterm_allow_proposed_api: Optional[bool] = False,
172
+ xterm_allow_transparency: Optional[bool] = False,
173
+ xterm_alt_click_moves_cursor: Optional[bool] = True,
174
+ xterm_convert_eol: Optional[bool] = False,
175
+ xterm_cursor_blink: Optional[bool] = False,
176
+ xterm_cursor_inactive_style: Literal[
177
+ "outline", "block", "bar", "underline", "none"
178
+ ] = "outline",
179
+ xterm_cursor_style: Literal["block", "underline", "bar"] = "block",
180
+ xterm_cursor_width: Optional[int] = 1,
181
+ xterm_custom_glyphs: Optional[bool] = False,
182
+ xterm_disable_stdin: Optional[bool] = True,
183
+ xterm_document_override: Optional[Any] = None,
184
+ xterm_draw_bold_text_in_bright_colors: Optional[bool] = True,
185
+ xterm_fast_scroll_modifier: Optional[
186
+ Literal["none", "alt", "ctrl", "shift"]
187
+ ] = "alt",
188
+ xterm_fast_scroll_sensitivity: Optional[int] = 1,
189
+ xterm_font_family: Optional[str] = "courier-new, courier, monospace",
190
+ xterm_font_size: Optional[int] = 15,
191
+ xterm_font_weight: Optional[FontWeight] = "normal",
192
+ xterm_font_weight_bold: Optional[FontWeight] = "bold",
193
+ xterm_ignore_bracketed_paste_mode: Optional[bool] = False,
194
+ xterm_letter_spacing: Optional[float] = 0,
195
+ xterm_line_height: Optional[float] = 1.0,
196
+ xterm_log_level: Optional[LogLevel] = "info",
197
+ xterm_mac_option_click_forces_selection: Optional[bool] = False,
198
+ xterm_mac_option_is_meta: Optional[bool] = False,
199
+ xterm_minimum_contrast_ratio: Optional[int] = 1,
200
+ xterm_overview_ruler_width: Optional[int] = 0,
201
+ xterm_rescale_overlapping_glyphs: Optional[bool] = False,
202
+ xterm_screen_reader_mode: Optional[bool] = False,
203
+ xterm_scroll_on_user_input: Optional[bool] = True,
204
+ xterm_scroll_sensitivity: Optional[int] = 1,
205
+ xterm_scrollback: Optional[int] = 1000,
206
+ xterm_smooth_scroll_duration: Optional[int] = 0,
207
+ xterm_tab_stop_width: Optional[int] = 8,
208
+ xterm_windows_mode: Optional[bool] = False,
209
  *,
210
  label: str | None = None,
211
  info: str | None = None,
 
221
  render: bool = True,
222
  ):
223
  """
224
+ For all the xterm options, please refer to the xterm.js documentation:
225
+ https://xtermjs.org/docs/api/terminal/interfaces/iterminaloptions/
226
+
227
  Parameters:
228
  log_file: the log file path to read from.
229
  tail: from the end of the file, the number of lines to start read from.
 
248
  self.fd = None
249
  self.stop_reading = False
250
 
251
+ self.xterm_allow_proposed_api = xterm_allow_proposed_api
252
+ self.xterm_allow_transparency = xterm_allow_transparency
253
+ self.xterm_alt_click_moves_cursor = xterm_alt_click_moves_cursor
254
+ self.xterm_convert_eol = xterm_convert_eol
255
+ self.xterm_cursor_blink = xterm_cursor_blink
256
+ self.xterm_cursor_inactive_style = xterm_cursor_inactive_style
257
+ self.xterm_cursor_style = xterm_cursor_style
258
+ self.xterm_cursor_width = xterm_cursor_width
259
+ self.xterm_custom_glyphs = xterm_custom_glyphs
260
+ self.xterm_disable_stdin = xterm_disable_stdin
261
+ self.xterm_document_override = xterm_document_override
262
+ self.xterm_draw_bold_text_in_bright_colors = (
263
+ xterm_draw_bold_text_in_bright_colors
264
+ )
265
+ self.xterm_fast_scroll_modifier = xterm_fast_scroll_modifier
266
+ self.xterm_fast_scroll_sensitivity = xterm_fast_scroll_sensitivity
267
+ self.xterm_font_family = xterm_font_family
268
+ self.xterm_font_size = xterm_font_size
269
+ self.xterm_font_weight = xterm_font_weight
270
+ self.xterm_font_weight_bold = xterm_font_weight_bold
271
+ self.xterm_ignore_bracketed_paste_mode = xterm_ignore_bracketed_paste_mode
272
+ self.xterm_letter_spacing = xterm_letter_spacing
273
+ self.xterm_line_height = xterm_line_height
274
+ self.xterm_log_level = xterm_log_level
275
+ self.xterm_mac_option_click_forces_selection = (
276
+ xterm_mac_option_click_forces_selection
277
+ )
278
+ self.xterm_mac_option_is_meta = xterm_mac_option_is_meta
279
+ self.xterm_minimum_contrast_ratio = xterm_minimum_contrast_ratio
280
+ self.xterm_overview_ruler_width = xterm_overview_ruler_width
281
+ self.xterm_rescale_overlapping_glyphs = xterm_rescale_overlapping_glyphs
282
+ self.xterm_screen_reader_mode = xterm_screen_reader_mode
283
+ self.xterm_scroll_on_user_input = xterm_scroll_on_user_input
284
+ self.xterm_scroll_sensitivity = xterm_scroll_sensitivity
285
+ self.xterm_scrollback = xterm_scrollback
286
+ self.xterm_smooth_scroll_duration = xterm_smooth_scroll_duration
287
+ self.xterm_tab_stop_width = xterm_tab_stop_width
288
+ self.xterm_windows_mode = xterm_windows_mode
289
+
290
  super().__init__(
291
  label=label,
292
  info=info,
 
317
  return {"type": "string"}
318
 
319
  def example_payload(self) -> Any:
320
+ pass
321
 
322
  def example_value(self) -> Any:
323
+ pass
324
 
325
 
326
  def load(self,
src/backend/gradio_log/templates/component/index.js CHANGED
The diff for this file is too large to render. See raw diff
 
src/demo/app.py CHANGED
@@ -1,11 +1,9 @@
1
- from pathlib import Path
2
  import logging
3
- import gradio as gr
4
 
 
5
  from gradio_log import Log
6
 
7
- import logging
8
-
9
 
10
  class CustomFormatter(logging.Formatter):
11
 
@@ -51,7 +49,6 @@ logger.info("The logs will be displayed in here.")
51
 
52
 
53
  def create_log_handler(level):
54
-
55
  def l(text):
56
  getattr(logger, level)(text)
57
 
@@ -64,7 +61,7 @@ with gr.Blocks() as demo:
64
  for l in ["debug", "info", "warning", "error", "critical"]:
65
  button = gr.Button(f"log as {l}")
66
  button.click(fn=create_log_handler(l), inputs=text)
67
- Log(log_file)
68
 
69
 
70
  if __name__ == "__main__":
 
 
1
  import logging
2
+ from pathlib import Path
3
 
4
+ import gradio as gr
5
  from gradio_log import Log
6
 
 
 
7
 
8
  class CustomFormatter(logging.Formatter):
9
 
 
49
 
50
 
51
  def create_log_handler(level):
 
52
  def l(text):
53
  getattr(logger, level)(text)
54
 
 
61
  for l in ["debug", "info", "warning", "error", "critical"]:
62
  button = gr.Button(f"log as {l}")
63
  button.click(fn=create_log_handler(l), inputs=text)
64
+ Log(log_file, dark=True)
65
 
66
 
67
  if __name__ == "__main__":
src/demo/space.py CHANGED
@@ -3,7 +3,7 @@ import gradio as gr
3
  from app import demo as app
4
  import os
5
 
6
- _docs = {'Log': {'description': 'Create a log component which can continuously read from a log file and display the content in a container.', 'members': {'__init__': {'log_file': {'type': 'str', 'default': 'None', 'description': 'the log file path to read from.'}, 'tail': {'type': 'int', 'default': '100', 'description': 'from the end of the file, the number of lines to start read from.'}, 'dark': {'type': 'bool', 'default': 'False', 'description': 'if True, will render the component in dark mode.'}, 'label': {'type': 'str | None', 'default': 'None', 'description': 'The label for this component. Appears above the component and is also used as the header if there are a table of examples for this component. If None and used in a `gr.Interface`, the label will be the name of the parameter this component is assigned to.'}, 'info': {'type': 'str | None', 'default': 'None', 'description': 'additional component description.'}, 'every': {'type': 'float', 'default': '0.3', 'description': 'New log pulling interval.'}, 'show_label': {'type': 'bool | None', 'default': 'None', 'description': 'if True, will display label.'}, 'container': {'type': 'bool', 'default': 'True', 'description': 'If True, will place the component in a container - providing some extra padding around the border.'}, 'scale': {'type': 'int | None', 'default': 'None', 'description': 'relative size compared to adjacent Components. For example if Components A and B are in a Row, and A has scale=2, and B has scale=1, A will be twice as wide as B. Should be an integer. scale applies in Rows, and to top-level Components in Blocks where fill_height=True.'}, 'min_width': {'type': 'int', 'default': '160', 'description': 'minimum pixel width, will wrap if not sufficient screen space to satisfy this value. If a certain scale value results in this Component being narrower than min_width, the min_width parameter will be respected first.'}, 'interactive': {'type': 'bool | None', 'default': 'None', 'description': 'if True, will be rendered as an editable textbox; if False, editing will be disabled. If not provided, this is inferred based on whether the component is used as an input or output.'}, 'visible': {'type': 'bool', 'default': 'True', 'description': 'If False, component will be hidden.'}, 'elem_id': {'type': 'str | None', 'default': 'None', 'description': 'An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.'}, 'elem_classes': {'type': 'list[str] | str | None', 'default': 'None', 'description': 'An optional list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.'}, 'render': {'type': 'bool', 'default': 'True', 'description': 'If False, component will not render be rendered in the Blocks context. Should be used if the intention is to assign event listeners now but render the component later.'}}, 'postprocess': {}, 'preprocess': {'return': {'type': 'typing.Any', 'description': "The preprocessed input data sent to the user's function in the backend."}, 'value': None}}, 'events': {'load': {'type': None, 'default': None, 'description': 'This listener is triggered when the Log initially loads in the browser.'}}}, '__meta__': {'additional_interfaces': {}, 'user_fn_refs': {'Log': []}}}
7
 
8
  abs_path = os.path.join(os.path.dirname(__file__), "css.css")
9
 
@@ -38,14 +38,12 @@ pip install gradio_log
38
  ## Usage
39
 
40
  ```python
41
- from pathlib import Path
42
  import logging
43
- import gradio as gr
44
 
 
45
  from gradio_log import Log
46
 
47
- import logging
48
-
49
 
50
  class CustomFormatter(logging.Formatter):
51
 
@@ -91,7 +89,6 @@ logger.info("The logs will be displayed in here.")
91
 
92
 
93
  def create_log_handler(level):
94
-
95
  def l(text):
96
  getattr(logger, level)(text)
97
 
@@ -104,7 +101,7 @@ with gr.Blocks() as demo:
104
  for l in ["debug", "info", "warning", "error", "critical"]:
105
  button = gr.Button(f"log as {l}")
106
  button.click(fn=create_log_handler(l), inputs=text)
107
- Log(log_file)
108
 
109
 
110
  if __name__ == "__main__":
@@ -145,7 +142,7 @@ The code snippet below is accurate in cases where the component is used as both
145
 
146
  ```python
147
  def predict(
148
- value: typing.Any
149
  ) -> Unknown:
150
  return value
151
  ```
 
3
  from app import demo as app
4
  import os
5
 
6
+ _docs = {'Log': {'description': 'Create a log component which can continuously read from a log file and display the content in a container.', 'members': {'__init__': {'log_file': {'type': 'str', 'default': 'None', 'description': 'the log file path to read from.'}, 'tail': {'type': 'int', 'default': '100', 'description': 'from the end of the file, the number of lines to start read from.'}, 'dark': {'type': 'bool', 'default': 'False', 'description': 'if True, will render the component in dark mode.'}, 'xterm_allow_proposed_api': {'type': 'bool | None', 'default': 'False', 'description': None}, 'xterm_allow_transparency': {'type': 'bool | None', 'default': 'False', 'description': None}, 'xterm_alt_click_moves_cursor': {'type': 'bool | None', 'default': 'True', 'description': None}, 'xterm_convert_eol': {'type': 'bool | None', 'default': 'False', 'description': None}, 'xterm_cursor_blink': {'type': 'bool | None', 'default': 'False', 'description': None}, 'xterm_cursor_inactive_style': {'type': '"outline" | "block" | "bar" | "underline" | "none"', 'default': '"outline"', 'description': None}, 'xterm_cursor_style': {'type': '"block" | "underline" | "bar"', 'default': '"block"', 'description': None}, 'xterm_cursor_width': {'type': 'int | None', 'default': '1', 'description': None}, 'xterm_custom_glyphs': {'type': 'bool | None', 'default': 'False', 'description': None}, 'xterm_disable_stdin': {'type': 'bool | None', 'default': 'True', 'description': None}, 'xterm_document_override': {'type': 'Any | None', 'default': 'None', 'description': None}, 'xterm_draw_bold_text_in_bright_colors': {'type': 'bool | None', 'default': 'True', 'description': None}, 'xterm_fast_scroll_modifier': {'type': '"none" | "alt" | "ctrl" | "shift" | None', 'default': '"alt"', 'description': None}, 'xterm_fast_scroll_sensitivity': {'type': 'int | None', 'default': '1', 'description': None}, 'xterm_font_family': {'type': 'str | None', 'default': '"courier-new, courier, monospace"', 'description': None}, 'xterm_font_size': {'type': 'int | None', 'default': '15', 'description': None}, 'xterm_font_weight': {'type': '"normal"\n | "bold"\n | "100"\n | "200"\n | "300"\n | "400"\n | "500"\n | "600"\n | "700"\n | "800"\n | "900"\n | None', 'default': '"normal"', 'description': None}, 'xterm_font_weight_bold': {'type': '"normal"\n | "bold"\n | "100"\n | "200"\n | "300"\n | "400"\n | "500"\n | "600"\n | "700"\n | "800"\n | "900"\n | None', 'default': '"bold"', 'description': None}, 'xterm_ignore_bracketed_paste_mode': {'type': 'bool | None', 'default': 'False', 'description': None}, 'xterm_letter_spacing': {'type': 'float | None', 'default': '0', 'description': None}, 'xterm_line_height': {'type': 'float | None', 'default': '1.0', 'description': None}, 'xterm_log_level': {'type': '"trace" | "debug" | "info" | "warn" | "error" | "off" | None', 'default': '"info"', 'description': None}, 'xterm_mac_option_click_forces_selection': {'type': 'bool | None', 'default': 'False', 'description': None}, 'xterm_mac_option_is_meta': {'type': 'bool | None', 'default': 'False', 'description': None}, 'xterm_minimum_contrast_ratio': {'type': 'int | None', 'default': '1', 'description': None}, 'xterm_overview_ruler_width': {'type': 'int | None', 'default': '0', 'description': None}, 'xterm_rescale_overlapping_glyphs': {'type': 'bool | None', 'default': 'False', 'description': None}, 'xterm_screen_reader_mode': {'type': 'bool | None', 'default': 'False', 'description': None}, 'xterm_scroll_on_user_input': {'type': 'bool | None', 'default': 'True', 'description': None}, 'xterm_scroll_sensitivity': {'type': 'int | None', 'default': '1', 'description': None}, 'xterm_scrollback': {'type': 'int | None', 'default': '1000', 'description': None}, 'xterm_smooth_scroll_duration': {'type': 'int | None', 'default': '0', 'description': None}, 'xterm_tab_stop_width': {'type': 'int | None', 'default': '8', 'description': None}, 'xterm_windows_mode': {'type': 'bool | None', 'default': 'False', 'description': None}, 'label': {'type': 'str | None', 'default': 'None', 'description': 'The label for this component. Appears above the component and is also used as the header if there are a table of examples for this component. If None and used in a `gr.Interface`, the label will be the name of the parameter this component is assigned to.'}, 'info': {'type': 'str | None', 'default': 'None', 'description': 'additional component description.'}, 'every': {'type': 'float', 'default': '0.3', 'description': 'New log pulling interval.'}, 'show_label': {'type': 'bool | None', 'default': 'None', 'description': 'if True, will display label.'}, 'container': {'type': 'bool', 'default': 'True', 'description': 'If True, will place the component in a container - providing some extra padding around the border.'}, 'scale': {'type': 'int | None', 'default': 'None', 'description': 'relative size compared to adjacent Components. For example if Components A and B are in a Row, and A has scale=2, and B has scale=1, A will be twice as wide as B. Should be an integer. scale applies in Rows, and to top-level Components in Blocks where fill_height=True.'}, 'min_width': {'type': 'int', 'default': '160', 'description': 'minimum pixel width, will wrap if not sufficient screen space to satisfy this value. If a certain scale value results in this Component being narrower than min_width, the min_width parameter will be respected first.'}, 'interactive': {'type': 'bool | None', 'default': 'None', 'description': 'if True, will be rendered as an editable textbox; if False, editing will be disabled. If not provided, this is inferred based on whether the component is used as an input or output.'}, 'visible': {'type': 'bool', 'default': 'True', 'description': 'If False, component will be hidden.'}, 'elem_id': {'type': 'str | None', 'default': 'None', 'description': 'An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.'}, 'elem_classes': {'type': 'list[str] | str | None', 'default': 'None', 'description': 'An optional list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.'}, 'render': {'type': 'bool', 'default': 'True', 'description': 'If False, component will not render be rendered in the Blocks context. Should be used if the intention is to assign event listeners now but render the component later.'}}, 'postprocess': {}, 'preprocess': {'return': {'type': 'Any', 'description': "The preprocessed input data sent to the user's function in the backend."}, 'value': None}}, 'events': {'load': {'type': None, 'default': None, 'description': 'This listener is triggered when the Log initially loads in the browser.'}}}, '__meta__': {'additional_interfaces': {}, 'user_fn_refs': {'Log': []}}}
7
 
8
  abs_path = os.path.join(os.path.dirname(__file__), "css.css")
9
 
 
38
  ## Usage
39
 
40
  ```python
 
41
  import logging
42
+ from pathlib import Path
43
 
44
+ import gradio as gr
45
  from gradio_log import Log
46
 
 
 
47
 
48
  class CustomFormatter(logging.Formatter):
49
 
 
89
 
90
 
91
  def create_log_handler(level):
 
92
  def l(text):
93
  getattr(logger, level)(text)
94
 
 
101
  for l in ["debug", "info", "warning", "error", "critical"]:
102
  button = gr.Button(f"log as {l}")
103
  button.click(fn=create_log_handler(l), inputs=text)
104
+ Log(log_file, dark=True)
105
 
106
 
107
  if __name__ == "__main__":
 
142
 
143
  ```python
144
  def predict(
145
+ value: Any
146
  ) -> Unknown:
147
  return value
148
  ```
src/frontend/Index.svelte CHANGED
@@ -26,6 +26,41 @@
26
  export let scale: number | null = null;
27
  export let min_width: number | undefined = undefined;
28
  export let loading_status: LoadingStatus | undefined = undefined;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
 
30
  let term;
31
  let termNode;
@@ -40,8 +75,42 @@
40
 
41
  onMount(() => {
42
  term = new xterm.Terminal({
43
- // allowTransparency: true,
44
  theme,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  });
46
  term.open(termNode);
47
  const fitAddon = new addon.FitAddon();
@@ -49,6 +118,16 @@
49
  setTimeout(() => {
50
  fitAddon.fit();
51
  }, 300);
 
 
 
 
 
 
 
 
 
 
52
  });
53
 
54
  $: if (term && value) {
 
26
  export let scale: number | null = null;
27
  export let min_width: number | undefined = undefined;
28
  export let loading_status: LoadingStatus | undefined = undefined;
29
+ export let xterm_allow_proposed_api;
30
+ export let xterm_allow_transparency;
31
+ export let xterm_alt_click_moves_cursor;
32
+ export let xterm_convert_eol;
33
+ export let xterm_cursor_blink;
34
+ export let xterm_cursor_inactive_style;
35
+ export let xterm_cursor_style;
36
+ export let xterm_cursor_width;
37
+ export let xterm_custom_glyphs;
38
+ export let xterm_disable_stdin;
39
+ export let xterm_document_override;
40
+ export let xterm_draw_bold_text_in_bright_colors;
41
+ export let xterm_fast_scroll_modifier;
42
+ export let xterm_fast_scroll_sensitivity;
43
+ export let xterm_font_family;
44
+ export let xterm_font_size;
45
+ export let xterm_font_weight;
46
+ export let xterm_font_weight_bold;
47
+ export let xterm_ignore_bracketed_paste_mode;
48
+ export let xterm_letter_spacing;
49
+ export let xterm_line_height;
50
+ export let xterm_log_level;
51
+ export let xterm_mac_option_click_forces_selection;
52
+ export let xterm_mac_option_is_meta;
53
+ export let xterm_minimum_contrast_ratio;
54
+ export let xterm_overview_ruler_width;
55
+ export let xterm_rescale_overlapping_glyphs;
56
+ export let xterm_right_click_selects_word;
57
+ export let xterm_screen_reader_mode;
58
+ export let xterm_scroll_on_user_input;
59
+ export let xterm_scroll_sensitivity;
60
+ export let xterm_scrollback;
61
+ export let xterm_smooth_scroll_duration;
62
+ export let xterm_tab_stop_width;
63
+ export let xterm_windows_mode;
64
 
65
  let term;
66
  let termNode;
 
75
 
76
  onMount(() => {
77
  term = new xterm.Terminal({
 
78
  theme,
79
+ allowProposedApi: xterm_allow_proposed_api,
80
+ allowTransparency: xterm_allow_transparency,
81
+ altClickMovesCursor: xterm_alt_click_moves_cursor,
82
+ convertEol: xterm_convert_eol,
83
+ cursorBlink: xterm_cursor_blink,
84
+ cursorInactiveStyle: xterm_cursor_inactive_style,
85
+ cursorStyle: xterm_cursor_style,
86
+ cursorWidth: xterm_cursor_width,
87
+ customGlyphs: xterm_custom_glyphs,
88
+ disableStdin: xterm_disable_stdin,
89
+ documentOverride: xterm_document_override,
90
+ drawBoldTextInBrightColors: xterm_draw_bold_text_in_bright_colors,
91
+ fastScrollModifier: xterm_fast_scroll_modifier,
92
+ fastScrollSensitivity: xterm_fast_scroll_sensitivity,
93
+ fontFamily: xterm_font_family,
94
+ fontSize: xterm_font_size,
95
+ fontWeight: xterm_font_weight,
96
+ fontWeightBold: xterm_font_weight_bold,
97
+ ignoreBracketedPasteMode: xterm_ignore_bracketed_paste_mode,
98
+ letterSpacing: xterm_letter_spacing,
99
+ lineHeight: xterm_line_height,
100
+ logLevel: xterm_log_level,
101
+ macOptionClickForcesSelection: xterm_mac_option_click_forces_selection,
102
+ macOptionIsMeta: xterm_mac_option_is_meta,
103
+ minimumContrastRatio: xterm_minimum_contrast_ratio,
104
+ overviewRulerWidth: xterm_overview_ruler_width,
105
+ rescaleOverlappingGlyphs: xterm_rescale_overlapping_glyphs,
106
+ rightClickSelectsWord: xterm_right_click_selects_word,
107
+ screenReaderMode: xterm_screen_reader_mode,
108
+ scrollOnUserInput: xterm_scroll_on_user_input,
109
+ scrollSensitivity: xterm_scroll_sensitivity,
110
+ smoothScrollDuration: xterm_smooth_scroll_duration,
111
+ tabStopWidth: xterm_tab_stop_width,
112
+ scrollback: xterm_scrollback,
113
+ windowsMode: xterm_windows_mode,
114
  });
115
  term.open(termNode);
116
  const fitAddon = new addon.FitAddon();
 
118
  setTimeout(() => {
119
  fitAddon.fit();
120
  }, 300);
121
+
122
+ const handleWindowResize = () => {
123
+ fitAddon.fit();
124
+ };
125
+
126
+ window.addEventListener("resize", handleWindowResize);
127
+
128
+ return () => {
129
+ window.removeEventListener("resize", handleWindowResize);
130
+ };
131
  });
132
 
133
  $: if (term && value) {
src/pyproject.toml CHANGED
@@ -8,7 +8,7 @@ build-backend = "hatchling.build"
8
 
9
  [project]
10
  name = "gradio_log"
11
- version = "0.0.3"
12
  description = "A Log component for Gradio which can easily show some log file in the interface."
13
  readme = "README.md"
14
  license = "Apache-2.0"
@@ -43,7 +43,7 @@ classifiers = [
43
  dev = ["build", "twine"]
44
 
45
  [tool.hatch.build]
46
- artifacts = ["/backend/gradio_log/templates", "*.pyi", "backend/gradio_log/templates", "backend/gradio_log/templates", "backend/gradio_log/templates", "backend/gradio_log/templates", "backend/gradio_log/templates", "backend/gradio_log/templates", "backend/gradio_log/templates"]
47
 
48
  [tool.hatch.build.targets.wheel]
49
  packages = ["/backend/gradio_log"]
 
8
 
9
  [project]
10
  name = "gradio_log"
11
+ version = "0.0.4"
12
  description = "A Log component for Gradio which can easily show some log file in the interface."
13
  readme = "README.md"
14
  license = "Apache-2.0"
 
43
  dev = ["build", "twine"]
44
 
45
  [tool.hatch.build]
46
+ artifacts = ["/backend/gradio_log/templates", "*.pyi", "backend/gradio_log/templates", "backend/gradio_log/templates", "backend/gradio_log/templates", "backend/gradio_log/templates", "backend/gradio_log/templates", "backend/gradio_log/templates", "backend/gradio_log/templates", "backend/gradio_log/templates"]
47
 
48
  [tool.hatch.build.targets.wheel]
49
  packages = ["/backend/gradio_log"]