summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorZbyszek Jędrzejewski-Szmek <zbyszek@in.waw.pl>2012-07-12 10:41:17 +0200
committerZbyszek Jędrzejewski-Szmek <zbyszek@in.waw.pl>2012-07-12 11:07:16 +0200
commit2b1a5c9ff41e6c48d9837a24e4afdafce34e74d4 (patch)
treee010fa290f2f1d40bfc02cfb1f968d75245ede52 /README.md
parent3eb019f875fc63eadfab29b4e0ad143409cf4cb2 (diff)
downloadpython-systemd-2b1a5c9ff41e6c48d9837a24e4afdafce34e74d4.tar.gz
Allow UTF-8 in message payload
Allow UTF-8, and force encoding as UTF-8 if the payload is known to be text. Under Python 3, this means that bytes payload is sent as-is, and strings are encoded to UTF-8. Under Python 2, this means that unicode payload is encoded to UTF-8, and the rest is sent as-is, because there we are missing the extra information to distinguish text and binary data. IOW, under Python 2, it is the responsibility of the called to provide properly encoded payload, and under Python 3, there is extra hand-holding which should help catch mistakes. Fields which are certain to be text (MESSAGE, MESSAGE_ID, CODE_FILE, CODE_FUNC) are text-only. The names of fields are text-only too. The payload of other fields can be binary.
Diffstat (limited to 'README.md')
-rw-r--r--README.md4
1 files changed, 2 insertions, 2 deletions
diff --git a/README.md b/README.md
index e21b601..3fc925e 100644
--- a/README.md
+++ b/README.md
@@ -21,7 +21,7 @@ Quick example:
import journald
journald.send('Hello world')
journald.send('Hello, again, world', FIELD2='Greetings!', FIELD3='Guten tag')
- journald.send('Binary message', BINARY='\xde\xad\xbe\xef')
+ journald.send('Binary message', BINARY=b'\xde\xad\xbe\xef')
There is one required argument -- the message, and additional fields
can be specified as keyword arguments. Following the journald API, all
@@ -33,7 +33,7 @@ The journald sendv call can also be accessed directly:
journald.sendv('MESSAGE=Hello world')
journald.sendv('MESSAGE=Hello, again, world', 'FIELD2=Greetings!',
'FIELD3=Guten tag')
- journald.sendv('MESSAGE=Binary message', 'BINARY=\xde\xad\xbe\xef')
+ journald.sendv('MESSAGE=Binary message', b'BINARY=\xde\xad\xbe\xef')
The two examples should give the same results in the log.