--------------------------------------------------------
--  DDL for Procedure LOG_COLLECTOR
--------------------------------------------------------
set define off;

  CREATE OR REPLACE EDITIONABLE PROCEDURE "ENVX_OPER"."LOG_COLLECTOR" (
    pi_program_name  IN  VARCHAR2,
    pi_log_level     IN  NUMBER,
    pi_log_message   IN  VARCHAR2
) AS
    v_log_level NUMBER := 0;
BEGIN
    ---
    SELECT to_number(parameter_value)
      INTO v_log_level
      FROM system_parameter p
     WHERE p.parameter_name = 'LOG_LEVEL';
    ---
    IF v_log_level > 0 AND pi_log_level <= v_log_level THEN
        ---
        INSERT INTO logs (
            message,
            date_time,
            order_log,
            program_name
        ) VALUES (
            pi_log_message,
            systimestamp,
            order_log.NEXTVAL,
            pi_program_name
        );
        ---
        COMMIT;
        ---
    END IF;

EXCEPTION
    WHEN OTHERS THEN
        NULL;
END log_collector;

/
