Coverage for curator/defaults/logging_defaults.py: 75%

1"""Define valid schemas for client configuration validation"""

2 from six import string_types

3 from voluptuous import All, Any, Coerce, Optional, Schema

4

5# Configuration file: logging

6 def config_logging():

7 """

8 Logging schema with defaults:

9

10 .. code-block:: yaml

11

12 logging:

13 loglevel: INFO

14 logfile: None

15 logformat: default

16 blacklist: ['elastic_transport', 'urllib3']

17

18 :returns: A valid :py:class:`~.voluptuous.schema_builder.Schema` of all acceptable values with

19 the default values set.

20 :rtype: :py:class:`~.voluptuous.schema_builder.Schema`

21 """

22 return Schema(

23 {

24 Optional('loglevel', default='INFO'):

25 Any(None, 'NOTSET', 'DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL',

26 All(Coerce(int), Any(0, 10, 20, 30, 40, 50))

27 ),

28 Optional('logfile', default=None): Any(None, *string_types),

29 Optional('logformat', default='default'):

30 Any(None, All(Any(*string_types), Any('default', 'json', 'logstash', 'ecs'))),

31 Optional('blacklist', default=['elastic_transport', 'urllib3']): Any(None, list),

32 }

33 )