python-elasticsearch-logger icon indicating copy to clipboard operation
python-elasticsearch-logger copied to clipboard

Add support for enum string parameters

Open johns1342 opened this issue 7 years ago • 0 comments

For configuring logging with YAML, it would be convenient to add support for enum strings for auth_type and index_name_frequency. By changing this line for auth_type in CMRESHandler.__init__() the code can take advantage of enum's support for string lookups:

        #self.auth_type = auth_type
        if isinstance(auth_type, CMRESHandler.AuthType):
            self.auth_type = auth_type
        else:
            try:
                self.auth_type = CMRESHandler.AuthType[auth_type]
            except KeyError:
                # preserve old behavior
                pass

P.S. Thank you for the package! It's been a great help for improving our Python logging.

johns1342 avatar Dec 06 '17 20:12 johns1342