Skip to content

Instantly share code, notes, and snippets.

@tcztzy
Created November 16, 2017 05:30
Show Gist options
  • Save tcztzy/3e4b8c96b84d5fad992f38c893476baa to your computer and use it in GitHub Desktop.
Save tcztzy/3e4b8c96b84d5fad992f38c893476baa to your computer and use it in GitHub Desktop.
Python logging dictionary configuration JSON schema
{
"title": "Python logging config dictionary schema",
"type": "object",
"definitions": {
"level": {
"title": "level",
"type": "string",
"enum": [
"NOTSET",
"DEBUG",
"INFO",
"WARNING",
"ERROR",
"CRITICAL"
],
"default": "WARNING"
},
"filter_ids": {
"title": "filters",
"type": "array",
"items": {
"title": "filter id",
"type": "string"
}
},
"formatter": {
"title": "formatter",
"description": "The configuring dict is searched for keys format and datefmt (with defaults of None) and these are used to construct a Formatter instance.",
"type": "object",
"properties": {
"format": { "type": [ "string", "null" ], "default": null },
"datefmt": { "type": [ "string", "null" ], "default": null }
},
"additionalProperties": false
},
"filter": {
"title": "filter",
"description": "The configuring dict is searched for the key name (defaulting to the empty string) and this is used to construct a logging.Filter instance.",
"type": "object",
"properties": {
"name": { "type": "string", "default": "" }
},
"additionalProperties": false
},
"handler": {
"title": "handler",
"type": "object",
"properties": {
"class": {
"title": "class",
"description": "This is the fully qualified name of the handler class.",
"type": "string"
},
"level": {
"$ref": "#/definitions/level",
"description": "The level of the handler."
},
"formatter": {
"title": "formatter",
"description": "The id of the formatter for this handler.",
"type": "string"
},
"filters": {
"$ref": "#/definitions/filter_ids",
"description": "A list of ids of the filters for this handler."
}
},
"required": [ "class" ],
"additionalProperties": true
},
"root_logger": {
"title": "root logger",
"type": "object",
"properties": {
"level": {
"$ref": "#/definitions/level",
"description": "The level of the logger."
},
"filters": {
"$ref": "#/definitions/filter_ids",
"description": "A list of ids of the filters for this logger."
},
"handlers": {
"title": "handlers",
"description": "A list of ids of the handlers for this logger.",
"type": "array",
"items": { "type": "string" }
}
},
"additionalProperties": false
},
"logger": {
"$ref": "#/definitions/root_logger",
"title": "logger",
"patternProperties": {
"^propagate$": {
"title": "propagate",
"description": "The propagation setting of the logger.",
"type": "boolean"
}
}
},
"user_defined_object": {
"title": "User-defined object",
"type": "object",
"properties": {
"()": {
"title": "factory",
"type": "string"
}
},
"additionalProperties": {
"title": "argument",
"type": "string"
},
"required": [ "()" ]
}
},
"properties": {
"version": {
"title": "version",
"description": "to be set to an integer value representing the schema version. The only valid value at present is 1, but having this key allows the schema to evolve while still preserving backwards compatibility",
"type": "integer",
"maximum": 1,
"minimum": 1,
"default": 1
},
"formatters": {
"title": "formatters",
"description": "the corresponding value will be a dict in which each key is a formatter id and each value is a dict describing how to configure the corresponding Formatter instance.",
"type": "object",
"patternProperties": {
"^.*$": {
"anyOf": [
{ "$ref": "#/definitions/formatter" },
{ "$ref": "#/definitions/user_defined_object" }
]
}
}
},
"filters": {
"title": "filters",
"description": "the corresponding value will be a dict in which each key is a filter id and each value is a dict describing how to configure the corresponding Filter instance.",
"type": "object",
"patternProperties": {
"^.*$": {
"anyOf": [
{ "$ref": "#/definitions/filter" },
{ "$ref": "#/definitions/user_defined_object" }
]
}
}
},
"handlers": {
"title": "handlers",
"description": "the corresponding value will be a dict in which each key is a handler id and each value is a dict describing how to configure the corresponding Handler instance.",
"type": "object",
"patternProperties": {
"^.*$": {
"anyOf": [
{ "$ref": "#/definitions/handler" },
{ "$ref": "#/definitions/user_defined_object" }
]
}
}
},
"loggers": {
"title": "loggers",
"description": "the corresponding value will be a dict in which each key is a logger name and each value is a dict describing how to configure the corresponding Logger instance.",
"type": "object",
"patternProperties": { "^.*$": { "$ref": "#/definitions/logger" } }
},
"root": {
"$ref": "#/definitions/root_logger"
},
"incremental": {
"title": "incremental",
"description": "whether the configuration is to be interpreted as incremental to the existing configuration. This value defaults to False, which means that the specified configuration replaces the existing configuration with the same semantics as used by the existing fileConfig() API.\n\nIf the specified value is True, the configuration is processed as described in the section on Incremental Configuration.",
"type": "boolean",
"default": false
},
"disable_existing_loggers": {
"title": "disable_existing_loggers",
"description": "whether any existing loggers are to be disabled. This setting mirrors the parameter of the same name in fileConfig(). If absent, this parameter defaults to True. This value is ignored if incremental is True.",
"type": "boolean",
"default": true
}
},
"required": [ "version" ],
"additionalProperties": false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment