Skip to main content

ZeroC Ice logging utils

Project description

logging.conf example

# https://docs.python.org/3.6/library/logging.config.html
#
# Level               Numeric value
# CRITICAL      50
# ERROR         40
# WARNING       30
# INFO          20
# DEBUG         10
# NOTSET        0
# higher level - less logs

[loggers]
keys=root

[handlers]
keys=consoleHandler

[logger_root]
level=DEBUG
handlers=consoleHandler

[handler_consoleHandler]
class=StreamHandler
level=DEBUG
formatter=consoleFormatter
args=(sys.stdout,)

[formatter_consoleFormatter]
class=ice_yml_log_formatter.YAMLLogFormatter
format=[%(levelname)s] %(name)s: %(msg)s
datefmt=

simple usage example

import os
import logging.config
import logging

logging.getLogger()
logging.config.fileConfig('./logging.conf')

#....
#....
# in your ice servant method
try:
  raise Exception('Any cause')
except:
  logging.exception('Oops!',
                    extra={
                      'ice_current': current,
                      'context': {
                        'any_info_key': 'any info value',
                      },
                    })

Use ice_current for ice request metatada print, and context for extra structured information.

log example

[DEBUG] services.fun - Dispatch
  iceIdentity: ZeroC/Fun
  iceOperation: something
  iceRequestId: 1

[ERROR] services.fun - Unexpected error
  iceIdentity: ZeroC/Fun
  iceOperation: something
  iceRequestId: 1
  context:
    any_info_key: any info value
  Error: Fun::ExampleException
    error_data:
      some_prop: 1
    stack_trace:
        File "path-to-source/fun.py", line 71, in wrapped
          return method(self, *args, **kwargs)

        File "path-to-source/fun.py", line 123, in something
          raise Fun.ExampleException(some_prop=1)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ice-yml-log-formatter-0.1.1.tar.gz (4.2 kB view details)

Uploaded Source

File details

Details for the file ice-yml-log-formatter-0.1.1.tar.gz.

File metadata

File hashes

Hashes for ice-yml-log-formatter-0.1.1.tar.gz
Algorithm Hash digest
SHA256 732dc83964acda92818ce198f339b7cf648e730042f8312f53b21bc4a65e69af
MD5 7105cc6777161c6e62ad804732d2f2f0
BLAKE2b-256 48213ebbed2d332ba1ec7048fb1999d8cd67a7563abd420c3778c86823482b18

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page