Skip to content

Commit 5914991

Browse files
committed
Add an hint about which client is loading the plugins
1 parent 692073c commit 5914991

File tree

1 file changed

+22
-16
lines changed

1 file changed

+22
-16
lines changed

pyrogram/client/client.py

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,8 +1176,8 @@ def load_plugins(self):
11761176
if isinstance(handler, Handler) and isinstance(group, int):
11771177
self.add_handler(handler, group)
11781178

1179-
log.info('[LOAD] {}("{}") in group {} from "{}"'.format(
1180-
type(handler).__name__, name, group, module_path))
1179+
log.info('[{}] [LOAD] {}("{}") in group {} from "{}"'.format(
1180+
self.session_name, type(handler).__name__, name, group, module_path))
11811181

11821182
count += 1
11831183
except Exception:
@@ -1190,11 +1190,13 @@ def load_plugins(self):
11901190
try:
11911191
module = import_module(module_path)
11921192
except ImportError:
1193-
log.warning('[LOAD] Ignoring non-existent module "{}"'.format(module_path))
1193+
log.warning('[{}] [LOAD] Ignoring non-existent module "{}"'.format(
1194+
self.session_name, module_path))
11941195
continue
11951196

11961197
if "__path__" in dir(module):
1197-
log.warning('[LOAD] Ignoring namespace "{}"'.format(module_path))
1198+
log.warning('[{}] [LOAD] Ignoring namespace "{}"'.format(
1199+
self.session_name, module_path))
11981200
continue
11991201

12001202
if handlers is None:
@@ -1209,14 +1211,14 @@ def load_plugins(self):
12091211
if isinstance(handler, Handler) and isinstance(group, int):
12101212
self.add_handler(handler, group)
12111213

1212-
log.info('[LOAD] {}("{}") in group {} from "{}"'.format(
1213-
type(handler).__name__, name, group, module_path))
1214+
log.info('[{}] [LOAD] {}("{}") in group {} from "{}"'.format(
1215+
self.session_name, type(handler).__name__, name, group, module_path))
12141216

12151217
count += 1
12161218
except Exception:
12171219
if warn_non_existent_functions:
1218-
log.warning('[LOAD] Ignoring non-existent function "{}" from "{}"'.format(
1219-
name, module_path))
1220+
log.warning('[{}] [LOAD] Ignoring non-existent function "{}" from "{}"'.format(
1221+
self.session_name, name, module_path))
12201222

12211223
if exclude is not None:
12221224
for path, handlers in exclude:
@@ -1226,11 +1228,13 @@ def load_plugins(self):
12261228
try:
12271229
module = import_module(module_path)
12281230
except ImportError:
1229-
log.warning('[UNLOAD] Ignoring non-existent module "{}"'.format(module_path))
1231+
log.warning('[{}] [UNLOAD] Ignoring non-existent module "{}"'.format(
1232+
self.session_name, module_path))
12301233
continue
12311234

12321235
if "__path__" in dir(module):
1233-
log.warning('[UNLOAD] Ignoring namespace "{}"'.format(module_path))
1236+
log.warning('[{}] [UNLOAD] Ignoring namespace "{}"'.format(
1237+
self.session_name, module_path))
12341238
continue
12351239

12361240
if handlers is None:
@@ -1245,19 +1249,21 @@ def load_plugins(self):
12451249
if isinstance(handler, Handler) and isinstance(group, int):
12461250
self.remove_handler(handler, group)
12471251

1248-
log.info('[UNLOAD] {}("{}") from group {} in "{}"'.format(
1249-
type(handler).__name__, name, group, module_path))
1252+
log.info('[{}] [UNLOAD] {}("{}") from group {} in "{}"'.format(
1253+
self.session_name, type(handler).__name__, name, group, module_path))
12501254

12511255
count -= 1
12521256
except Exception:
12531257
if warn_non_existent_functions:
1254-
log.warning('[UNLOAD] Ignoring non-existent function "{}" from "{}"'.format(
1255-
name, module_path))
1258+
log.warning('[{}] [UNLOAD] Ignoring non-existent function "{}" from "{}"'.format(
1259+
self.session_name, name, module_path))
12561260

12571261
if count > 0:
1258-
log.warning('Successfully loaded {} plugin{} from "{}"'.format(count, "s" if count > 1 else "", root))
1262+
log.warning('[{}] Successfully loaded {} plugin{} from "{}"'.format(
1263+
self.session_name, count, "s" if count > 1 else "", root))
12591264
else:
1260-
log.warning('No plugin loaded from "{}"'.format(root))
1265+
log.warning('[{}] No plugin loaded from "{}"'.format(
1266+
self.session_name, root))
12611267

12621268
def save_session(self):
12631269
auth_key = base64.b64encode(self.auth_key).decode()

0 commit comments

Comments
 (0)