mirror of
https://codeberg.org/StreamGraph/StreamGraph.git
synced 2024-11-13 19:49:55 +01:00
add logger and logger renderer
This commit is contained in:
parent
3c0a12d005
commit
d6b26eda21
8 changed files with 189 additions and 6 deletions
|
@ -6,6 +6,8 @@ class_name DeckHolder
|
||||||
#static var decks: Array[Deck]
|
#static var decks: Array[Deck]
|
||||||
static var decks: Dictionary # Dictionary[String -> id, (Deck|Dictionary[String -> instance_id, Deck])]
|
static var decks: Dictionary # Dictionary[String -> id, (Deck|Dictionary[String -> instance_id, Deck])]
|
||||||
|
|
||||||
|
static var logger := Logger.new()
|
||||||
|
|
||||||
|
|
||||||
## Returns a new empty deck and assigns a new random ID to it.
|
## Returns a new empty deck and assigns a new random ID to it.
|
||||||
static func add_empty_deck() -> Deck:
|
static func add_empty_deck() -> Deck:
|
||||||
|
|
39
classes/deck/logger.gd
Normal file
39
classes/deck/logger.gd
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
class_name Logger
|
||||||
|
|
||||||
|
enum LogType {
|
||||||
|
INFO,
|
||||||
|
WARN,
|
||||||
|
ERROR,
|
||||||
|
}
|
||||||
|
|
||||||
|
enum LogCategory {
|
||||||
|
NODE,
|
||||||
|
DECK,
|
||||||
|
SYSTEM,
|
||||||
|
RENDERER,
|
||||||
|
}
|
||||||
|
|
||||||
|
signal log_message(text: String, type: LogType, category: LogCategory)
|
||||||
|
|
||||||
|
|
||||||
|
func log_node(text: Variant, type: LogType = LogType.INFO) -> void:
|
||||||
|
self.log(str(text), type, LogCategory.NODE)
|
||||||
|
|
||||||
|
|
||||||
|
func log_deck(text: Variant, type: LogType = LogType.INFO) -> void:
|
||||||
|
self.log(str(text), type, LogCategory.DECK)
|
||||||
|
|
||||||
|
|
||||||
|
func log_system(text: Variant, type: LogType = LogType.INFO) -> void:
|
||||||
|
self.log(str(text), type, LogCategory.SYSTEM)
|
||||||
|
|
||||||
|
|
||||||
|
func log_renderer(text: Variant, type: LogType = LogType.INFO) -> void:
|
||||||
|
self.log(str(text), type, LogCategory.RENDERER)
|
||||||
|
|
||||||
|
|
||||||
|
func log(text: String, type: LogType, category: LogCategory) -> void:
|
||||||
|
log_message.emit(text, type, category)
|
||||||
|
|
||||||
|
if OS.has_feature("editor"):
|
||||||
|
prints(LogType.keys()[type].capitalize(), LogCategory.keys()[category].capitalize(), text)
|
|
@ -35,12 +35,13 @@ func _receive(to_input_port: int, data: Variant, extra_data: Array = []) -> void
|
||||||
return
|
return
|
||||||
|
|
||||||
var data_to_print = resolve_input_port_value(0)
|
var data_to_print = resolve_input_port_value(0)
|
||||||
if data_to_print == null:
|
if data_to_print == null || data_to_print.is_empty():
|
||||||
data_to_print = str(data)
|
data_to_print = str(data)
|
||||||
|
|
||||||
times_activated += 1
|
times_activated += 1
|
||||||
|
|
||||||
# var data_to_print = input_ports[0].value_callback.call()
|
# var data_to_print = input_ports[0].value_callback.call()
|
||||||
print(data_to_print)
|
#print(data_to_print)
|
||||||
print("extra data: ", extra_data)
|
#print("extra data: ", extra_data)
|
||||||
|
DeckHolder.logger.log_node(data_to_print)
|
||||||
send(0, true)
|
send(0, true)
|
||||||
|
|
|
@ -50,6 +50,7 @@ var _deck_to_save: WeakRef
|
||||||
|
|
||||||
@onready var obs_setup_dialog := $OBSWebsocketSetupDialog as OBSWebsocketSetupDialog
|
@onready var obs_setup_dialog := $OBSWebsocketSetupDialog as OBSWebsocketSetupDialog
|
||||||
@onready var twitch_setup_dialog := $Twitch_Setup_Dialog as TwitchSetupDialog
|
@onready var twitch_setup_dialog := $Twitch_Setup_Dialog as TwitchSetupDialog
|
||||||
|
@onready var logger_renderer: LoggerRenderer = %LoggerRenderer
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
|
@ -87,6 +88,10 @@ func _ready() -> void:
|
||||||
file_popup_menu.set_item_shortcut(FileMenuId.SAVE, save_deck_shortcut)
|
file_popup_menu.set_item_shortcut(FileMenuId.SAVE, save_deck_shortcut)
|
||||||
file_popup_menu.set_item_shortcut(FileMenuId.SAVE_AS, save_deck_as_shortcut)
|
file_popup_menu.set_item_shortcut(FileMenuId.SAVE_AS, save_deck_as_shortcut)
|
||||||
file_popup_menu.set_item_shortcut(FileMenuId.CLOSE, close_deck_shortcut)
|
file_popup_menu.set_item_shortcut(FileMenuId.CLOSE, close_deck_shortcut)
|
||||||
|
|
||||||
|
DeckHolder.logger.log_renderer("normal test")
|
||||||
|
DeckHolder.logger.log_renderer("warning test", Logger.LogType.WARN)
|
||||||
|
DeckHolder.logger.log_renderer("error test", Logger.LogType.ERROR)
|
||||||
|
|
||||||
|
|
||||||
## Called when the File button in the [MenuBar] is pressed with the [param id]
|
## Called when the File button in the [MenuBar] is pressed with the [param id]
|
||||||
|
@ -393,3 +398,9 @@ func _on_unsaved_changes_dialog_confirmed() -> void:
|
||||||
close_tab(i)
|
close_tab(i)
|
||||||
|
|
||||||
get_tree().quit()
|
get_tree().quit()
|
||||||
|
|
||||||
|
|
||||||
|
func _unhandled_input(event: InputEvent) -> void:
|
||||||
|
if event.is_action_pressed("toggle_console"):
|
||||||
|
logger_renderer.visible = !logger_renderer.visible
|
||||||
|
accept_event()
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
[gd_scene load_steps=20 format=3 uid="uid://duaah5x0jhkn6"]
|
[gd_scene load_steps=21 format=3 uid="uid://duaah5x0jhkn6"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://graph_node_renderer/deck_holder_renderer.gd" id="1_67g2g"]
|
[ext_resource type="Script" path="res://graph_node_renderer/deck_holder_renderer.gd" id="1_67g2g"]
|
||||||
[ext_resource type="PackedScene" uid="uid://b84f2ngtcm5b8" path="res://graph_node_renderer/tab_container_custom.tscn" id="1_s3ug2"]
|
[ext_resource type="PackedScene" uid="uid://b84f2ngtcm5b8" path="res://graph_node_renderer/tab_container_custom.tscn" id="1_s3ug2"]
|
||||||
[ext_resource type="Theme" uid="uid://dqqdqscid2iem" path="res://graph_node_renderer/default_theme.tres" id="1_tgul2"]
|
[ext_resource type="Theme" uid="uid://dqqdqscid2iem" path="res://graph_node_renderer/default_theme.tres" id="1_tgul2"]
|
||||||
[ext_resource type="Script" path="res://addons/no-obs-ws/NoOBSWS.gd" id="4_nu72u"]
|
[ext_resource type="Script" path="res://addons/no-obs-ws/NoOBSWS.gd" id="4_nu72u"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://duvh3r740w2p5" path="res://graph_node_renderer/logger_renderer.tscn" id="4_pvexk"]
|
||||||
[ext_resource type="Script" path="res://addons/no_twitch/twitch_connection.gd" id="5_3n36q"]
|
[ext_resource type="Script" path="res://addons/no_twitch/twitch_connection.gd" id="5_3n36q"]
|
||||||
[ext_resource type="PackedScene" uid="uid://eioso6jb42jy" path="res://graph_node_renderer/obs_websocket_setup_dialog.tscn" id="5_uo2gj"]
|
[ext_resource type="PackedScene" uid="uid://eioso6jb42jy" path="res://graph_node_renderer/obs_websocket_setup_dialog.tscn" id="5_uo2gj"]
|
||||||
[ext_resource type="PackedScene" uid="uid://bq2lxmbnic4lc" path="res://graph_node_renderer/twitch_setup_dialog.tscn" id="7_7rhap"]
|
[ext_resource type="PackedScene" uid="uid://bq2lxmbnic4lc" path="res://graph_node_renderer/twitch_setup_dialog.tscn" id="7_7rhap"]
|
||||||
|
@ -85,7 +86,7 @@ theme_override_constants/margin_bottom = 2
|
||||||
|
|
||||||
[node name="VSplitContainer" type="VSplitContainer" parent="MarginContainer"]
|
[node name="VSplitContainer" type="VSplitContainer" parent="MarginContainer"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
split_offset = 677
|
split_offset = 460
|
||||||
|
|
||||||
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/VSplitContainer"]
|
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/VSplitContainer"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
@ -136,7 +137,9 @@ item_0/id = 0
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
|
||||||
[node name="ConsoleContainer" type="PanelContainer" parent="MarginContainer/VSplitContainer"]
|
[node name="LoggerRenderer" parent="MarginContainer/VSplitContainer" instance=ExtResource("4_pvexk")]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
visible = false
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
|
||||||
[node name="FileDialog" type="FileDialog" parent="."]
|
[node name="FileDialog" type="FileDialog" parent="."]
|
||||||
|
|
43
graph_node_renderer/logger_renderer.gd
Normal file
43
graph_node_renderer/logger_renderer.gd
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
extends PanelContainer
|
||||||
|
class_name LoggerRenderer
|
||||||
|
|
||||||
|
@onready var output_label: RichTextLabel = %OutputLabel
|
||||||
|
@onready var copy_button: Button = %CopyButton
|
||||||
|
@onready var clear_button: Button = %ClearButton
|
||||||
|
|
||||||
|
const COLORS := {
|
||||||
|
Logger.LogType.INFO: Color.WHITE,
|
||||||
|
Logger.LogType.WARN: Color("f4f486"),
|
||||||
|
Logger.LogType.ERROR: Color("f47c7c"),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
clear_button.pressed.connect(
|
||||||
|
func():
|
||||||
|
output_label.clear()
|
||||||
|
output_label.text = ""
|
||||||
|
output_label.push_context()
|
||||||
|
)
|
||||||
|
DeckHolder.logger.log_message.connect(_on_logger_log_message)
|
||||||
|
output_label.push_context()
|
||||||
|
|
||||||
|
# the copy button is disabled for now because it doesnt work
|
||||||
|
copy_button.pressed.connect(
|
||||||
|
func():
|
||||||
|
var c = output_label.get_text()
|
||||||
|
DisplayServer.clipboard_set(output_label.get_text())
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
func _on_logger_log_message(text: String, type: Logger.LogType, category: Logger.LogCategory) -> void:
|
||||||
|
output_label.pop_context()
|
||||||
|
output_label.push_context()
|
||||||
|
var category_text: String = Logger.LogCategory.keys()[category].capitalize()
|
||||||
|
category_text = "(%s)" % category_text
|
||||||
|
output_label.push_bold()
|
||||||
|
output_label.add_text("%s: " % category_text)
|
||||||
|
output_label.pop()
|
||||||
|
output_label.push_color(COLORS[type])
|
||||||
|
output_label.add_text(text)
|
||||||
|
output_label.newline()
|
79
graph_node_renderer/logger_renderer.tscn
Normal file
79
graph_node_renderer/logger_renderer.tscn
Normal file
|
@ -0,0 +1,79 @@
|
||||||
|
[gd_scene load_steps=4 format=3 uid="uid://duvh3r740w2p5"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://graph_node_renderer/logger_renderer.gd" id="1_82rlk"]
|
||||||
|
|
||||||
|
[sub_resource type="SystemFont" id="SystemFont_1dh4a"]
|
||||||
|
font_names = PackedStringArray("Monospace")
|
||||||
|
|
||||||
|
[sub_resource type="SystemFont" id="SystemFont_0uj5d"]
|
||||||
|
font_names = PackedStringArray("Monospace")
|
||||||
|
font_weight = 700
|
||||||
|
|
||||||
|
[node name="LoggerRenderer" type="PanelContainer"]
|
||||||
|
anchors_preset = -1
|
||||||
|
anchor_right = 0.42016
|
||||||
|
anchor_bottom = 0.181704
|
||||||
|
offset_right = -0.0240021
|
||||||
|
offset_bottom = 0.255997
|
||||||
|
script = ExtResource("1_82rlk")
|
||||||
|
metadata/_edit_use_anchors_ = true
|
||||||
|
|
||||||
|
[node name="MarginContainer" type="MarginContainer" parent="."]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_constants/margin_left = 3
|
||||||
|
theme_override_constants/margin_top = 3
|
||||||
|
theme_override_constants/margin_right = 3
|
||||||
|
theme_override_constants/margin_bottom = 3
|
||||||
|
|
||||||
|
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="MarginContainer/VBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "Debug Console"
|
||||||
|
|
||||||
|
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_vertical = 3
|
||||||
|
|
||||||
|
[node name="PanelContainer" type="PanelContainer" parent="MarginContainer/VBoxContainer/HBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
|
||||||
|
[node name="MarginContainer" type="MarginContainer" parent="MarginContainer/VBoxContainer/HBoxContainer/PanelContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_constants/margin_left = 3
|
||||||
|
theme_override_constants/margin_top = 3
|
||||||
|
theme_override_constants/margin_right = 3
|
||||||
|
theme_override_constants/margin_bottom = 3
|
||||||
|
|
||||||
|
[node name="OutputLabel" type="RichTextLabel" parent="MarginContainer/VBoxContainer/HBoxContainer/PanelContainer/MarginContainer"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
focus_mode = 2
|
||||||
|
theme_override_fonts/normal_font = SubResource("SystemFont_1dh4a")
|
||||||
|
theme_override_fonts/bold_font = SubResource("SystemFont_0uj5d")
|
||||||
|
theme_override_font_sizes/normal_font_size = 12
|
||||||
|
theme_override_font_sizes/bold_font_size = 13
|
||||||
|
scroll_following = true
|
||||||
|
context_menu_enabled = true
|
||||||
|
threaded = true
|
||||||
|
selection_enabled = true
|
||||||
|
deselect_on_focus_loss_enabled = false
|
||||||
|
drag_and_drop_selection_enabled = false
|
||||||
|
|
||||||
|
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/VBoxContainer/HBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
alignment = 1
|
||||||
|
|
||||||
|
[node name="CopyButton" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer/VBoxContainer"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
visible = false
|
||||||
|
layout_mode = 2
|
||||||
|
text = "Copy"
|
||||||
|
|
||||||
|
[node name="ClearButton" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer/VBoxContainer"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
layout_mode = 2
|
||||||
|
text = "Clear"
|
|
@ -43,6 +43,11 @@ rename_node={
|
||||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194333,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194333,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
toggle_console={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":78,"key_label":0,"unicode":110,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
[rendering]
|
[rendering]
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue