Skip to content

Commit a4a0448

Browse files
committed
Fix: Log-messages get formatted even if not output.
One should not use str.format() for log messages, as this will format the string even if it is dropped due to the log level. Instead leave formatting to the logging module .
1 parent 3831a29 commit a4a0448

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

anonip.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def run(self):
121121
if not line:
122122
break
123123

124-
logger.debug("Got line: {}".format(line))
124+
logger.debug("Got line: %r", line)
125125

126126
yield self.process_line(line)
127127

@@ -141,9 +141,7 @@ def process_ip(self, ip):
141141
trunc_ip = trunc_ip + self.increment
142142
except ipaddress.AddressValueError:
143143
logger.error(
144-
"Could not increment IP {} by {}".format(
145-
trunc_ip, self.increment
146-
)
144+
"Could not increment IP %s by %s", trunc_ip, self.increment
147145
)
148146
return trunc_ip
149147

@@ -163,7 +161,7 @@ def process_line(self, line):
163161
try:
164162
loglist[decindex]
165163
except IndexError:
166-
logger.warning("Column {} does not exist!".format(index))
164+
logger.warning("Column %s does not exist!", index)
167165
continue
168166
else:
169167
ip_str, ip = self.extract_ip(loglist[decindex])

0 commit comments

Comments
 (0)