DirectoryTree / LdapRecord-Laravel

Multi-domain LDAP Authentication & Management for Laravel.
https://ldaprecord.com/docs/laravel/v3
MIT License
483 stars 51 forks source link

[Feature] Make Log Level configurable #599

Closed nilskretschmer closed 8 months ago

nilskretschmer commented 8 months ago

Describe the feature you'd like: Make Log Level configurable.

How? Currently inside the Loggable Trait:

<?php

namespace LdapRecord\Laravel\Events;

use Illuminate\Support\Facades\Config;

trait Loggable
{
    /**
     * Get the level of log message (i.e. info, alert, critical).
     */
    public function getLogLevel(): string
    {
        return 'info';
    }

    /**
     * Determine if event should be logged.
     */
    public function shouldLogEvent(): bool
    {
        return Config::get('ldap.logging.enabled', false);
    }
}

Change the getLogLevel-function to:

    /**
     * Get the level of log message (i.e. info, alert, critical).
     */
    public function getLogLevel(): string
    {
        return Config::get('ldap.logging.level', 'info');
    }

As well as adding a new config value inside the config/ldap.php file:

    'logging' => [
        'enabled' => env('LDAP_LOGGING', true),
        'channel' => env('LOG_CHANNEL', 'stack'),
        'level' => env('LDAP_LOGGING_LEVEL', 'info'),
    ],

Why? It would be nice to be able to set the logging level so it can be adjusted to other application-wide loggings. Maybe developers want to use the debug-Log-Level as default for their application's logs - as well as for ldap logging.