Installing zato-enclog for Python applications

The only step required to install zato-enclog outside of Zato is to pull it from PyPI, for instance, using pip:

$ sudo pip install zato-enclog
Collecting zato-enclog
  Downloading zato-enclog-x.y.z.tar.gz


Installing collected packages: zato-enclog
  Running install for zato-enclog
$ enclog demo

Plain text: {"user":"Jane Xi"}
Key:        D_VAfbXkabCKLnEx-xm0CP4c41JOIlK0p1c-pTzm2dY=
Encrypted:  gAAAAABWZyfBUJHc1iEPaIkmSHrkXMCkRTZco-aoAzRR7kNqMtHLtd7qrWj9WKBpYCa [...]
Decrypted:  {"user":"Jane Xi"}



import logging
from zato.enclog import EncryptedLogFormatter, genkey

level = logging.INFO
format = '%(levelname)s - %(message)s'

key = genkey()
formatter = EncryptedLogFormatter(key, format)

handler = logging.StreamHandler()

logger = logging.getLogger('')
logger.setLevel(level)'This will be encrypted')

Note that the key is the only means to decrypt encrypted logs. Should it be lost, no decryption will be possible.

Use enclog open and enclog tailf to read encrypted logs.