TEXT
PACKAGE xpp_log
is
/**
 * Project:         Project (<a href="http://en.1stsw.com/products/extreme-parallel-processing/"> XPP 1. SOFTWAROV┴ s.r.o.</a>)
 * Description:     Package for loging trace log into XPP_TRACE_LOG table.
 * <p> 
 * @author          Petr Jezek
 * @version         2.0.1, 2012-09-19
 * @since           1.0 
 * @headcom
 */

/**
 * List of exceptions
 */
  c_err_missing_debug_level   constant PLS_INTEGER := -20041;
  c_err_missing_maintance_par constant PLS_INTEGER := -20042;

/**
 * List of statuses of g_log_level
 */
  c_fatal              constant pls_integer := 1;
  c_error              constant pls_integer := 2;
  c_warning            constant pls_integer := 3;
  c_info               constant pls_integer := 4;
  c_debug              constant pls_integer := 5;
  c_user_log           constant pls_integer := 6;

/**
 * Variable g_log_level is globaly defined for whole log package.
 * It is initially loaded from setting from XPP_CONF_PARAM table.
 * In exceptional case it can be overloaded.
 */
  g_log_level          number := null;

/**
 * It is initially loading value of global variable g_log_level from XPP_CONF_PARAM.
 * When configuration is not set correctly the debug level, then it raise exception MISSING_DEBUG_LEVEL.
 * According the debug level is apropriate call of log_trace inserted record into XPP_TRACE_LOG table.
 * Note: Part of the insert into log is pragma autonomous_transaction. 
 * <p>
 * @param p_severity_id     Specifies severity level. Possible values are: 1 - fatal, 2 - error, 3 - warning, 4 - info, 5 - debug
 * @param p_procedure_name  The name of procedure identify the procedure where was cerated the log record  
 * @param p_msg             The content of message for the log (table XPP_TRACE_LOG).
 * @throws c_err_missing_debug_level There is missing configuration of log level in XPP_CONF_PARAM table. The should be column NAME = 'LOG_LEVEL' with column VAL with numeric value. Then of VAL should be one of the "List of statuses"
 *
 */
  procedure add_log(
    p_severity_id    in number   -- 1 - fatal, 2 - error, 3 - warning, 4 - info, 5 - debug
   ,p_procedure_name in varchar2 -- Name of procedure for log
   ,p_msg            in varchar2 -- Trace description. Max length for log is 4000.
  );


/**
 * It is maintance procedure to delete old data in XPP_TRACE_LOG table.
 * There is expected in table XPP_CONF_PARAM configuration (NAME = 'CLEAN_OLDER_THEN_X_DAYS') with number of days.
 * Records in XPP_TRACE_LOG older then CLEAN_OLDER_THEN_X_DAYS days will be automaticly delete weekly by job.
 * Note: Part of the insert into log is pragma autonomous_transaction.  
 * <p>
 * @param none There are no parameters.
 * @throws c_err_missing_maintance_par there is missing configuration of log level in XPP_CONF_PARAM table (in table XPP_CONF_PARAM should be column NAME = 'CLEAN_OLDER_THEN_X_DAYS' where column VAL with is numeric value and higer then 0).
 */   
  procedure clean_old_logs;


end xpp_log;