diff options
author | Zbyszek Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2012-07-12 10:41:17 +0200 |
---|---|---|
committer | Zbyszek Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2012-07-12 11:07:16 +0200 |
commit | 2b1a5c9ff41e6c48d9837a24e4afdafce34e74d4 (patch) | |
tree | e010fa290f2f1d40bfc02cfb1f968d75245ede52 /README.md | |
parent | 3eb019f875fc63eadfab29b4e0ad143409cf4cb2 (diff) | |
download | python-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.md | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -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. |