------------------------------------
-- logger_file_typ
-- 日志文件输出
------------------------------------
CREATE OR REPLACE TYPE logger_file_typ UNDER logger_typ
(
OVERRIDING MEMBER PROCEDURE write( MSG IN logmsg_typ )
) NOT final;
/
CREATE OR REPLACE TYPE BODY logger_file_typ AS
OVERRIDING MEMBER PROCEDURE write( MSG IN logmsg_typ ) IS
FH UTL_FILE.FILE_TYPE;
v_DIR varchar2(1000);
v_FILE varchar2(1000);
BEGIN
v_DIR := cb.GET_CONFIG_VALUE('APL_LOG_DIR');
v_FILE := cb.GET_CONFIG_VALUE('APL_LOG_FILE');
IF v_DIR is NULL or v_FILE is NULL THEN RETURN; END IF;
-- 打开文件
FH := UTL_FILE.FOPEN( v_DIR,
v_FILE,
'A',
32767);
UTL_FILE.PUT_LINE(FH,
MSG.LOG_DATE || ' ' ||
MSG.LOG_LEVEL || ' ' ||
MSG.LOG_MSG || ' ' ||
MSG.LOG_HOST || ' ' ||
MSG.LOG_OSUSER || ' ' ||
MSG.LOG_PRG || ' ' ||
MSG.LOG_SUPPLE );
UTL_FILE.FCLOSE(FH);
EXCEPTION
WHEN OTHERS THEN
UTL_FILE.FCLOSE_ALL;
DBMS_OUTPUT.PUT_LINE(SQLCODE);
DBMS_OUTPUT.PUT_LINE(SQLERRM);
END;
-- logger_file_typ
-- 日志文件输出
------------------------------------
CREATE OR REPLACE TYPE logger_file_typ UNDER logger_typ
(
OVERRIDING MEMBER PROCEDURE write( MSG IN logmsg_typ )
) NOT final;
/
CREATE OR REPLACE TYPE BODY logger_file_typ AS
OVERRIDING MEMBER PROCEDURE write( MSG IN logmsg_typ ) IS
FH UTL_FILE.FILE_TYPE;
v_DIR varchar2(1000);
v_FILE varchar2(1000);
BEGIN
v_DIR := cb.GET_CONFIG_VALUE('APL_LOG_DIR');
v_FILE := cb.GET_CONFIG_VALUE('APL_LOG_FILE');
IF v_DIR is NULL or v_FILE is NULL THEN RETURN; END IF;
-- 打开文件
FH := UTL_FILE.FOPEN( v_DIR,
v_FILE,
'A',
32767);
UTL_FILE.PUT_LINE(FH,
MSG.LOG_DATE || ' ' ||
MSG.LOG_LEVEL || ' ' ||
MSG.LOG_MSG || ' ' ||
MSG.LOG_HOST || ' ' ||
MSG.LOG_OSUSER || ' ' ||
MSG.LOG_PRG || ' ' ||
MSG.LOG_SUPPLE );
UTL_FILE.FCLOSE(FH);
EXCEPTION
WHEN OTHERS THEN
UTL_FILE.FCLOSE_ALL;
DBMS_OUTPUT.PUT_LINE(SQLCODE);
DBMS_OUTPUT.PUT_LINE(SQLERRM);
END;