1 PACKAGE BODY AST_DEBUG_PUB as
2 /* $Header: astidbgb.pls 115.4 2003/01/07 19:38:35 karamach ship $ */
3 -- Start of Comments
4 -- Package name : AST_DEBUG_PUB
5 -- Purpose :
6 -- History :
7 -- NOTE :
8 -- End of Comments
9
10 Function OpenFile(P_File in varchar2 ) Return Varchar2 IS
11 rtn_val Varchar2(100);
12 Begin
13
14 if G_DIR is null then
15 select value INTO G_DIR
16 from v$PARAMETER where name = 'utl_file_dir';
17 if instr(G_DIR,',') > 0 then
18 G_DIR := substr(G_DIR,1,instr(G_DIR,',')-1);
19 end if;
20 END IF;
21
22
23 if P_FILE is null then
24 -- select substr('l'|| substr(to_char(sysdate,'MI'),1,1)
25 -- || lpad(AST_debug_file_s.nextval,6,'0'),1,8) || '.AST'
26 --into G_FILE from dual;
27
28 SELECT sid || '.AST' into G_FILE
29 FROM v$session
30 WHERE audsid = Userenv('SESSIONID');
31
32 G_FILE_PTR := utl_file.fopen(G_DIR, G_FILE, 'w');
33 else
34 G_FILE :=P_File;
35 G_FILE_PTR := utl_file.fopen(G_DIR, G_FILE, 'a');
36 end if;
37
38 rtn_val := G_DIR || '/' || g_file;
39
40 return(rtn_val);
41 Exception
42 WHEN OTHERS then
43 return(null);
44 End OpenFile;
45
46
47 -- PROCEDURE LogMessage
48 --
49 -- Usage Used to log message to the debug file
50
51 PROCEDURE LogMessage(debug_msg in Varchar2,
52 debug_level in Number default 1,
53 print_date in varchar2 default 'N')
54
55 IS
56 rtn_val Varchar2(100);
57 BEGIN
58
59 if (G_Debug_Level >= debug_level) then
60 rtn_val:=OpenFile(G_FILE);
61 if print_date = 'Y' then
62 utl_file.put_line(G_FILE_PTR, to_char( sysdate, 'DD-MON-YYYY HH:MI:SS' ) || ' ' || debug_msg );
63
64 else
65 utl_file.put_line(G_FILE_PTR, ' ' ||debug_msg);
66 end if; --if print date is 'Y'
67
68 -- Write and close the file
69 utl_file.fflush(G_FILE_PTR);
70 utl_file.fclose(G_FILE_PTR);
71
72 end if;-- debug level is big enough
73
74 Exception
75 WHEN OTHERS then
76 null;
77 END LogMessage; -- LogMessage
78
79
80 -- PROCEDURE SetDebugLevel
81 --
82 -- Usage set debug level if running outside of application otherwise debuglevel
83 -- is taken from the profile value
84
85 Procedure SetDebugLevel(p_debug_level in number)
86 IS
87 Begin
88 AST_DEBUG_PUB.G_DEBUG_LEVEL := p_debug_level;
89 End SetDebugLevel;
90
91
92
93 END AST_DEBUG_PUB;