Skip to content

Configuration Guide

cbabil edited this page Sep 12, 2024 · 5 revisions

The configuration.yml file serves as the main configuration for PyPluginizer. This file centralizes the configuration for the application, logging, core plugins, user plugins, and hooks, making it easy to manage and scale the framework's functionality. Below is a detailed explanation of each section in the file.

File structure

 app:
  name: "PyPluginizer"
  description: "A Plugin framework written in python"

  # Logger
  logger:
    level: "INFO"
    format: "%(asctime)s,%(msecs)03d %(levelname)-8s [%(filename)s:%(lineno)d] %(message)s"
    
  # Core plugins
  core:
    directory: ./src/plugins/core

  # Users plugins
  users:
    directory: ./src/plugins/users

  # Hooks
  hooks:
    directory: ./src/hooks

Detailed Breakdown

1. Application Metadata

The app section contains basic metadata about the PyPluginizer application, such as its name and description.

name: The name of the application. In this case, it's set to PyPluginizer.

description: A brief description of what the application does. This can help users and developers understand the purpose of the app.

 app:
  name: "PyPluginizer"
  description: "A Plugin framework written in python"

2. Logger Configuration

The logger section defines how logging will behave in the PyPluginizer framework. It allows setting the log level and formatting the output of log messages.

level: Defines the level of logging. Common options include DEBUG, INFO, WARNING, ERROR, and CRITICAL. In this configuration, it is set to INFO, which provides general operational messages.

format: Specifies the format of the log output. The default format used is:

"%(asctime)s,%(msecs)03d %(levelname)-8s [%(filename)s:%(lineno)d] %(message)s"

This format will output:

  • The timestamp (%(asctime)s)
  • Milliseconds (%(msecs))
  • Log level (e.g., INFO, ERROR) padded to 8 characters (%(levelname)-8s)
  • The file where the log was generated (%(filename)s)
  • The line number (%(lineno)d)
  • The actual log message (%(message)s)

Alternate logging formats are provided in comments for flexibility, such as including process IDs or modifying the timestamp format.

logger:
  level: "INFO"
  format: "%(asctime)s,%(msecs)03d %(levelname)-8s [%(filename)s:%(lineno)d] %(message)s"

3. Core Plugins

The core section specifies where the core plugins are located. These plugins are essential to the framework's functionality and are generally developed and maintained by the application developers.

directory: The directory where core plugins reside. In this example, the path is ./src/plugins/core.

core:
  directory: ./src/plugins/core

4. User Plugins

The users section handles the configuration for user-defined plugins. These plugins are typically written by users who wish to extend the functionality of the framework.

directory: This points to the folder where user plugins are stored. The default location is ./src/plugins/users.

users:
  directory: ./src/plugins/users

5. Hooks

The hooks section is used to define where hook scripts or modules are located. Hooks are points in the framework where custom behavior can be "hooked" or triggered by events in the application.

directory: Specifies the folder where the hook scripts or modules are located. The default directory for hooks is ./src/hooks.

hooks:
  directory: ./src/hooks

Summary

The configuration.yml file is essential for managing various aspects of the PyPluginizer framework, from defining where core and user plugins are located to configuring the logging output and integrating hooks for custom functionality. Each section in the configuration file has a specific role in ensuring the flexibility and maintainability of the plugin framework.

Clone this wiki locally