Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python: Log multiple strings to one line

Title says it all, I need to log two strings in one line.
For example, something like this:

logging.info(string1,string2)

Thank you :)

like image 586
josh Avatar asked Sep 21 '13 20:09

josh


1 Answers

The logging functions act like this:

result = arg1 % (arg2, arg3, ...)

What you have will try to format the first string with the second string:

result = string1 % string2

Either manually specify a formatting string:

logging.info('%s %s', string1, string2)

Or join them together into one string:

logging.info(' '.join([string1, string2]))
like image 149
Blender Avatar answered Sep 28 '22 10:09

Blender