Skip to content

Commit 098f351

Browse files
improve logging
1 parent bfcb722 commit 098f351

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

git_archive.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,15 @@ def ensure_repo_cloned(self, server_id: str) -> Optional[Repo]:
9393

9494
if os.path.exists(repo_path):
9595
# Repo exists, open and pull
96-
print(f'\t[Git Archive] Opening existing repo at {repo_path}')
96+
print(f'\t[Git Archive] [{server_id}] Opening existing repo at {repo_path}')
9797
repo = Repo(repo_path)
9898
try:
9999
repo.remotes.origin.pull()
100100
except GitCommandError as e:
101-
print(f'\t[Git Archive] Warning: Could not pull: {e}')
101+
print(f'\t[Git Archive] [{server_id}] Warning: Could not pull: {e}')
102102
else:
103103
# Clone the repo
104-
print(f'\t[Git Archive] Cloning {repo_url} to {repo_path}')
104+
print(f'\t[Git Archive] [{server_id}] Cloning {repo_url} to {repo_path}')
105105
os.makedirs(repo_path, exist_ok=True)
106106
repo = Repo.clone_from(auth_url, repo_path, branch=branch)
107107

@@ -275,15 +275,15 @@ async def flush_and_commit(self, channel) -> None:
275275
date_range.append(date_str)
276276

277277
if total_new == 0:
278-
print(f'\t[Git Archive] No new messages to commit for #{channel_name}')
278+
print(f'\t[Git Archive] [{server_id}] No new messages to commit for #{channel_name}')
279279
return
280280

281281
# Stage all changes
282282
repo.git.add(A=True)
283283

284284
# Check if there are staged changes
285285
if not repo.is_dirty(index=True):
286-
print(f'\t[Git Archive] No changes to commit for #{channel_name}')
286+
print(f'\t[Git Archive] [{server_id}] No changes to commit for #{channel_name}')
287287
return
288288

289289
# Create commit message
@@ -294,16 +294,16 @@ async def flush_and_commit(self, channel) -> None:
294294
date_info = f"{date_range[0]} to {date_range[-1]}"
295295

296296
commit_message = f"Archive {total_new} messages from #{channel_name} ({date_info})"
297-
print(f'\t[Git Archive] {commit_message}')
297+
print(f'\t[Git Archive] [{server_id}] {commit_message}')
298298

299299
repo.index.commit(commit_message)
300300

301301
# Push changes
302302
try:
303303
repo.remotes.origin.push()
304-
print(f'\t[Git Archive] Pushed changes for #{channel_name}')
304+
print(f'\t[Git Archive] [{server_id}] Pushed changes for #{channel_name}')
305305
except GitCommandError as e:
306-
print(f'\t[Git Archive] Warning: Could not push: {e}')
306+
print(f'\t[Git Archive] [{server_id}] Warning: Could not push: {e}')
307307

308308

309309
def is_git_archive_enabled() -> bool:
@@ -334,6 +334,15 @@ def init_git_archive() -> Optional[GitArchiveManager]:
334334
try:
335335
config = GitArchiveConfig(config_path)
336336
print('[Git Archive] Initialized successfully')
337+
338+
# Print configured servers and their repos
339+
servers = config.config.get('servers', {})
340+
for server_id, server_config in servers.items():
341+
enabled = server_config.get('enabled', False)
342+
repo_url = server_config.get('repo_url', 'N/A')
343+
status = 'enabled' if enabled else 'disabled'
344+
print(f'[Git Archive] Server {server_id}: {repo_url} ({status})')
345+
337346
return GitArchiveManager(config, clone_path, github_token)
338347
except FileNotFoundError as e:
339348
print(f'[Git Archive] Warning: {e}')

main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ async def on_ready():
600600
if not isinstance(channel, nextcord.TextChannel):
601601
continue
602602

603-
print(f'Backing up Channel {channel.name} on {channel.guild.name}')
603+
print(f'[{channel.guild.id}] Backing up Channel {channel.name} on {channel.guild.name}')
604604

605605
# Backup channels
606606
print('\tRetrieving last message Id')
@@ -612,7 +612,7 @@ async def on_ready():
612612

613613
# Backup threads in channel
614614
for thread in channel.threads:
615-
print(f'Backing up Thread {thread.id} in Channel {channel.name} on {channel.guild.name}')
615+
print(f'[{channel.guild.id}] Backing up Thread {thread.id} in Channel {channel.name} on {channel.guild.name}')
616616

617617
last_msg_id = await get_last_message_id(thread)
618618
new_last_msg_id = await backup_channel(thread, last_msg_id)

0 commit comments

Comments
 (0)