Replace print statements with proper logging
This commit is contained in:
parent
60d4b32cd8
commit
4006ed7c34
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
import logging
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import List
|
from typing import List
|
||||||
import gi
|
import gi
|
||||||
@ -26,6 +27,8 @@ gi.require_version('GLib', '2.0')
|
|||||||
from gi.repository import GLib
|
from gi.repository import GLib
|
||||||
from .models import HistoryEntry
|
from .models import HistoryEntry
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class HistoryManager:
|
class HistoryManager:
|
||||||
"""Manages request history persistence to JSON file."""
|
"""Manages request history persistence to JSON file."""
|
||||||
@ -53,7 +56,7 @@ class HistoryManager:
|
|||||||
|
|
||||||
return [HistoryEntry.from_dict(entry) for entry in data.get('entries', [])]
|
return [HistoryEntry.from_dict(entry) for entry in data.get('entries', [])]
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error loading history: {e}")
|
logger.error(f"Error loading history: {e}")
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def save_history(self, entries: List[HistoryEntry]):
|
def save_history(self, entries: List[HistoryEntry]):
|
||||||
@ -67,7 +70,7 @@ class HistoryManager:
|
|||||||
with open(self.history_file, 'w') as f:
|
with open(self.history_file, 'w') as f:
|
||||||
json.dump(data, f, indent=2)
|
json.dump(data, f, indent=2)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error saving history: {e}")
|
logger.error(f"Error saving history: {e}")
|
||||||
|
|
||||||
def add_entry(self, entry: HistoryEntry):
|
def add_entry(self, entry: HistoryEntry):
|
||||||
"""Add new entry to history and save."""
|
"""Add new entry to history and save."""
|
||||||
|
|||||||
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
import json
|
import json
|
||||||
import uuid
|
import uuid
|
||||||
|
import logging
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
from datetime import datetime, timezone
|
from datetime import datetime, timezone
|
||||||
@ -27,6 +28,8 @@ gi.require_version('GLib', '2.0')
|
|||||||
from gi.repository import GLib
|
from gi.repository import GLib
|
||||||
from .models import Project, SavedRequest, HttpRequest, Environment
|
from .models import Project, SavedRequest, HttpRequest, Environment
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class ProjectManager:
|
class ProjectManager:
|
||||||
"""Manages project and saved request persistence."""
|
"""Manages project and saved request persistence."""
|
||||||
@ -53,7 +56,7 @@ class ProjectManager:
|
|||||||
data = json.load(f)
|
data = json.load(f)
|
||||||
return [Project.from_dict(p) for p in data.get('projects', [])]
|
return [Project.from_dict(p) for p in data.get('projects', [])]
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error loading projects: {e}")
|
logger.error(f"Error loading projects: {e}")
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def save_projects(self, projects: List[Project]):
|
def save_projects(self, projects: List[Project]):
|
||||||
@ -66,7 +69,7 @@ class ProjectManager:
|
|||||||
with open(self.projects_file, 'w') as f:
|
with open(self.projects_file, 'w') as f:
|
||||||
json.dump(data, f, indent=2)
|
json.dump(data, f, indent=2)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error saving projects: {e}")
|
logger.error(f"Error saving projects: {e}")
|
||||||
|
|
||||||
def add_project(self, name: str) -> Project:
|
def add_project(self, name: str) -> Project:
|
||||||
"""Create new project with default environment."""
|
"""Create new project with default environment."""
|
||||||
|
|||||||
@ -21,11 +21,14 @@ import gi
|
|||||||
gi.require_version('GtkSource', '5')
|
gi.require_version('GtkSource', '5')
|
||||||
from gi.repository import Adw, Gtk, GLib, GtkSource, GObject
|
from gi.repository import Adw, Gtk, GLib, GtkSource, GObject
|
||||||
from typing import Optional, Set, Dict, List
|
from typing import Optional, Set, Dict, List
|
||||||
|
import logging
|
||||||
from .models import HttpRequest, HttpResponse
|
from .models import HttpRequest, HttpResponse
|
||||||
from .widgets.header_row import HeaderRow
|
from .widgets.header_row import HeaderRow
|
||||||
import json
|
import json
|
||||||
import xml.dom.minidom
|
import xml.dom.minidom
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class RequestTabWidget(Gtk.Box):
|
class RequestTabWidget(Gtk.Box):
|
||||||
"""Widget representing a single request tab's UI."""
|
"""Widget representing a single request tab's UI."""
|
||||||
@ -1125,7 +1128,7 @@ class RequestTabWidget(Gtk.Box):
|
|||||||
dom = xml.dom.minidom.parseString(body)
|
dom = xml.dom.minidom.parseString(body)
|
||||||
return dom.toprettyxml(indent=" ")
|
return dom.toprettyxml(indent=" ")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Failed to format body: {e}")
|
logger.debug(f"Failed to format response body: {e}")
|
||||||
|
|
||||||
return body
|
return body
|
||||||
|
|
||||||
|
|||||||
@ -20,10 +20,13 @@
|
|||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
import uuid
|
import uuid
|
||||||
import json
|
import json
|
||||||
|
import logging
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from .models import RequestTab, HttpRequest, HttpResponse
|
from .models import RequestTab, HttpRequest, HttpResponse
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class TabManager:
|
class TabManager:
|
||||||
"""Manages open request tabs."""
|
"""Manages open request tabs."""
|
||||||
@ -147,6 +150,6 @@ class TabManager:
|
|||||||
|
|
||||||
except (FileNotFoundError, json.JSONDecodeError, KeyError) as e:
|
except (FileNotFoundError, json.JSONDecodeError, KeyError) as e:
|
||||||
# If session file is invalid, start fresh
|
# If session file is invalid, start fresh
|
||||||
print(f"Failed to load session: {e}")
|
logger.warning(f"Failed to load session: {e}")
|
||||||
self.tabs = []
|
self.tabs = []
|
||||||
self.active_tab_id = None
|
self.active_tab_id = None
|
||||||
|
|||||||
@ -21,6 +21,7 @@ import gi
|
|||||||
gi.require_version('GtkSource', '5')
|
gi.require_version('GtkSource', '5')
|
||||||
from gi.repository import Adw, Gtk, GLib, Gio, GtkSource
|
from gi.repository import Adw, Gtk, GLib, Gio, GtkSource
|
||||||
from typing import Dict, Optional
|
from typing import Dict, Optional
|
||||||
|
import logging
|
||||||
from .models import HttpRequest, HttpResponse, HistoryEntry, RequestTab
|
from .models import HttpRequest, HttpResponse, HistoryEntry, RequestTab
|
||||||
from .http_client import HttpClient
|
from .http_client import HttpClient
|
||||||
from .history_manager import HistoryManager
|
from .history_manager import HistoryManager
|
||||||
@ -35,6 +36,8 @@ from datetime import datetime
|
|||||||
import json
|
import json
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@Gtk.Template(resource_path='/cz/vesp/roster/main-window.ui')
|
@Gtk.Template(resource_path='/cz/vesp/roster/main-window.ui')
|
||||||
class RosterWindow(Adw.ApplicationWindow):
|
class RosterWindow(Adw.ApplicationWindow):
|
||||||
@ -493,7 +496,7 @@ class RosterWindow(Adw.ApplicationWindow):
|
|||||||
substituted_request, undefined = VariableSubstitution.substitute_request(modified_request, env)
|
substituted_request, undefined = VariableSubstitution.substitute_request(modified_request, env)
|
||||||
# Log undefined variables for debugging
|
# Log undefined variables for debugging
|
||||||
if undefined:
|
if undefined:
|
||||||
print(f"Warning: Undefined variables in request: {', '.join(undefined)}")
|
logger.warning(f"Undefined variables in request: {', '.join(undefined)}")
|
||||||
|
|
||||||
# Disable send button during request
|
# Disable send button during request
|
||||||
widget.send_button.set_sensitive(False)
|
widget.send_button.set_sensitive(False)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user