Visitar URL original
fix: logging statemant using f-string · hydrogram/hydrogram@032f0d5 · GitHub
Skip to content

Commit 032f0d5

Browse files
committed
fix: logging statemant using f-string
1 parent f5fc9ad commit 032f0d5

3 files changed

Lines changed: 33 additions & 7 deletions

File tree

‎hydrogram/client.py‎

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,12 @@ def load_plugins(self):
708708
self.add_handler(handler, group)
709709

710710
log.info(
711-
f'[{self.name}] [LOAD] {type(handler).__name__}("{name}") in group {group} from "{module_path}"'
711+
"[%s] [LOAD] %s('%s') in group %s from '%s'",
712+
self.name,
713+
type(handler).__name__,
714+
name,
715+
group,
716+
module_path,
712717
)
713718

714719
count += 1
@@ -746,14 +751,22 @@ def load_plugins(self):
746751
self.add_handler(handler, group)
747752

748753
log.info(
749-
f'[{self.name}] [LOAD] {type(handler).__name__}("{name}") in group {group} from "{module_path}"'
754+
"[%s] [LOAD] %s('%s') in group %s from '%s'",
755+
self.name,
756+
type(handler).__name__,
757+
name,
758+
group,
759+
module_path,
750760
)
751761

752762
count += 1
753763
except Exception:
754764
if warn_non_existent_functions:
755765
log.warning(
756-
f'[{self.name}] [LOAD] Ignoring non-existent function "{name}" from "{module_path}"'
766+
"[%s] [LOAD] Ignoring non-existent function '%s' from '%s'",
767+
self.name,
768+
name,
769+
module_path,
757770
)
758771

759772
if exclude:
@@ -790,19 +803,31 @@ def load_plugins(self):
790803
self.remove_handler(handler, group)
791804

792805
log.info(
793-
f'[{self.name}] [UNLOAD] {type(handler).__name__}("{name}") from group {group} in "{module_path}"'
806+
"[%s] [UNLOAD] %s('%s') from group '%s' in '%s'",
807+
self.name,
808+
type(handler).__name__,
809+
name,
810+
group,
811+
module_path,
794812
)
795813

796814
count -= 1
797815
except Exception:
798816
if warn_non_existent_functions:
799817
log.warning(
800-
f'[{self.name}] [UNLOAD] Ignoring non-existent function "{name}" from "{module_path}"'
818+
"[%s] [UNLOAD] Ignoring non-existent function '%s' from '%s'",
819+
self.name,
820+
name,
821+
module_path,
801822
)
802823

803824
if count > 0:
804825
log.info(
805-
f'[{self.name}] Successfully loaded {count} plugin{"s" if count > 1 else ""} from "{root}"'
826+
"[%s] Successfully loaded %s plugin%s from '%s'",
827+
self.name,
828+
count,
829+
"" if count == 1 else "s",
830+
root,
806831
)
807832
else:
808833
log.warning('[%s] No plugin loaded from "%s"', self.name, root)

‎hydrogram/methods/utilities/idle.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ async def main():
7373
task = None
7474

7575
def signal_handler(signum, __):
76-
logging.info(f"Stop signal received ({signals[signum]}). Exiting...")
76+
logging.info("Stop signal received (%s). Exiting...", signals[signum])
7777
task.cancel()
7878

7979
for s in (SIGINT, SIGTERM, SIGABRT):

‎pyproject.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ select = [
108108
"PERF", # perflint
109109
"N", # pep8-naming
110110
"RUF", # ruff
111+
"G", # flake8-logging-format
111112
]
112113
ignore = ["RUF001", "RUF002", "RUF003", "E203", "PERF203"]
113114
preview = true

0 commit comments

Comments
 (0)