Update logging level for plugin loading and extend static example documentation
- Changed logging level from `info` to `debug` in plugin loading to reduce verbosity during runtime. - Significantly expanded `examples/static/README.md` with new sections, examples (basic, certbot, deny pages, JWT validator), and detailed usage instructions. - Improved `examples/docker/docker-compose-changed-label.yml` with clearer redirect syntax using JSON for better readability. - Fixed handling of empty or invalid JSON in labels within `easymapping` with fallback to default values and error logging. - Added additional entries to `.gitignore` to exclude dynamic and temporary files like auto-generated configuration files and certificates.
This commit is contained in:
parent
3a4b428e46
commit
99f4ff325b
7 changed files with 384 additions and 403 deletions
|
|
@ -4,6 +4,7 @@ import os
|
|||
import re
|
||||
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
from functions import loggerEasyHaproxy
|
||||
|
||||
|
||||
class DockerLabelHandler:
|
||||
|
|
@ -32,7 +33,16 @@ class DockerLabelHandler:
|
|||
|
||||
def get_json(self, label, default_value={}):
|
||||
if self.has_label(label):
|
||||
return json.loads(self.__data[label])
|
||||
value = self.__data[label]
|
||||
if not value: # Handle empty strings
|
||||
return default_value
|
||||
try:
|
||||
return json.loads(value)
|
||||
except json.JSONDecodeError as e:
|
||||
loggerEasyHaproxy.error(
|
||||
f"Invalid JSON in label '{label}': {value}. Error: {e}. Using default value."
|
||||
)
|
||||
return default_value
|
||||
return default_value
|
||||
|
||||
def set_data(self, data):
|
||||
|
|
@ -67,8 +77,7 @@ class HaproxyConfigGenerator:
|
|||
self.global_plugin_configs = []
|
||||
except Exception as e:
|
||||
# If plugin system fails to initialize, log but continue
|
||||
import logging
|
||||
logging.warning(f"Failed to initialize plugin system: {e}")
|
||||
loggerEasyHaproxy.warning(f"Failed to initialize plugin system: {e}")
|
||||
self.plugin_manager = None
|
||||
self.global_plugin_configs = []
|
||||
|
||||
|
|
@ -102,8 +111,7 @@ class HaproxyConfigGenerator:
|
|||
global_configs = [r.haproxy_config for r in global_results if r.haproxy_config]
|
||||
self.global_plugin_configs.extend(global_configs)
|
||||
except Exception as e:
|
||||
import logging
|
||||
logging.warning(f"Failed to execute global plugins: {e}")
|
||||
loggerEasyHaproxy.warning(f"Failed to execute global plugins: {e}")
|
||||
|
||||
templates_dir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'templates')
|
||||
file_loader = FileSystemLoader(templates_dir)
|
||||
|
|
@ -274,8 +282,7 @@ class HaproxyConfigGenerator:
|
|||
if result.metadata["fcgi_app_definition"] not in self.global_plugin_configs:
|
||||
self.global_plugin_configs.append(result.metadata["fcgi_app_definition"])
|
||||
except Exception as e:
|
||||
import logging
|
||||
logging.warning(f"Failed to execute domain plugins for {hostname}: {e}")
|
||||
loggerEasyHaproxy.warning(f"Failed to execute domain plugins for {hostname}: {e}")
|
||||
easymapping[port]["hosts"][hostname]["plugin_configs"] = []
|
||||
else:
|
||||
easymapping[port]["hosts"][hostname]["plugin_configs"] = []
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import os
|
||||
import logging
|
||||
|
||||
from deepdiff import DeepDiff
|
||||
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ class PluginManager:
|
|||
elif plugin.plugin_type == PluginType.DOMAIN:
|
||||
self.domain_plugins.append(plugin)
|
||||
|
||||
self.logger.info(f"Loaded {source} plugin: {plugin.name} ({plugin.plugin_type.value})")
|
||||
self.logger.debug(f"Loaded {source} plugin: {plugin.name} ({plugin.plugin_type.value})")
|
||||
|
||||
except Exception as e:
|
||||
self._handle_error(f"Failed to load plugin from {filepath}: {str(e)}")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue