[Home] [Help]
Skip to content
PACKAGE BODY: APPS.ASO_DEBUG_PUB
Source
1 PACKAGE BODY ASO_DEBUG_PUB as
2 /* $Header: asoidbgb.pls 120.1 2005/06/29 12:33:02 appldev ship $ */
3 -- Start of Comments
4 -- Package name : ASO_DEBUG_PUB
5 -- Purpose :
6 -- History :
7 -- NOTE :
8 -- End of Comments
9
10 Function Set_Debug_Mode(P_Mode in varchar2) Return Varchar2 IS
11 rtn_val Varchar2(100);
12 l_dbgfile_number number;
13 Begin
14
15
16 if P_MODE = 'FILE' then
17
18 G_DEBUG_MODE := 'FILE';
19 OE_DEBUG_PUB.G_DEBUG_MODE := 'FILE';
20 if G_FILE is null then
21 --IF (ASO_DEBUG_PUB.G_FILE is NULL OR ASO_DEBUG_PUB.G_FILE <> 'ASO'||FND_GLOBAL.USER_NAME||'.dbg') Then
22 select aso_debug_file_s.nextval
23 into l_dbgfile_number
24 from dual;
25
26 G_FILE := substr('l'|| substr(to_char(sysdate,'MI'),1,1)
27 || lpad(l_dbgfile_number,6,'0'),1,8)
28 || fnd_global.user_name
29 || '.dbg';
30
31 G_FILE_PTR := utl_file.fopen(G_DIR, G_FILE, 'a');
32 oe_debug_pub.G_FILE_PTR := G_FILE_PTR;
33 end if;
34 rtn_val := G_DIR || '/' || g_file;
35 elsif P_MODE = 'CONC' then
36 --G_DEBUG_MODE := 'CONC';
37 rtn_val := null;
38 else
39 --G_DEBUG_MODE := 'TABLE';
40 rtn_val := null;
41 end if;
42
43 aso_debug_pub.setdebuglevel(G_Debug_Level);
44 aso_debug_pub.debug_on;
45
46 return(rtn_val);
47 Exception when others then
48 G_DEBUG_MODE := 'FILE';
49 --rtn_val := null;
50 return(rtn_val);
51 End;
52
53
54 PROCEDURE Initialize
55 IS
56 BEGIN
57
58 G_Debug_tbl.DELETE;
59 G_Debug_count := 0;
60 G_Debug_index := 0;
61
62 OE_DEBUG_PUB.G_Debug_tbl.DELETE;
63 OE_DEBUG_PUB.G_Debug_count := 0;
64 OE_DEBUG_PUB.G_Debug_index := 0;
65 OE_DEBUG_PUB.G_DIR := ASO_DEBUG_PUB.G_DIR;
66 OE_DEBUG_PUB.G_FILE := ASO_DEBUG_PUB.G_FILE;
67
68 END Initialize;
69
70
71 Procedure Debug_ON
72 IS
73 Begin
74 ASO_DEBUG_PUB.G_DEBUG := FND_API.G_TRUE;
75 --OE_DEBUG_PUB.G_DEBUG := FND_API.G_TRUE;
76 End Debug_On;
77
78
79 Procedure Debug_OFF
80 IS
81 Begin
82 ASO_DEBUG_PUB.G_DEBUG := FND_API.G_FALSE;
83 OE_DEBUG_PUB.G_DEBUG := FND_API.G_FALSE;
84 End Debug_Off;
85
86
87 Function ISDebugOn
88 Return Boolean IS
89 Begin
90 if ASO_DEBUG_PUB.G_DEBUG = FND_API.G_TRUE then
91 RETURN(TRUE);
92 else
93 RETURN(FALSE);
94 end if;
95 End ISDebugOn;
96
97
98 -- FUNCTION Count_Debug
99 --
100 -- Usage Used by API callers and developers to find the count
101 -- of Debugs in the message list.
102 -- Desc Returns the value of G_Debug_count
103 --
104 -- Parameters None
105 --
106 -- Return NUMBER
107
108 FUNCTION CountDebug RETURN NUMBER
109 IS
110 BEGIN
111
112 RETURN G_Debug_Count;
113
114 END CountDebug;
115
116
117 -- PROCEDURE Add
118 --
119 -- Usage Used to add Debugs to the global message table.
120
121 PROCEDURE Add(debug_msg in Varchar2, debug_level in Number := 1, print_date in varchar2 := 'N' )
122 IS
123 l_fname VARCHAR2(80);
124 l_date varchar2(80);
125
126 BEGIN
127
128
129 if ASO_DEBUG_PUB.G_FILE = 'OFF' then
130 return;
131 end if;
132
133 if ASO_DEBUG_PUB.G_FILE is null then
134 if nvl(fnd_profile.value('ASO_ENABLE_DEBUG'),'N') = 'Y' then
135 aso_debug_pub.SetDebugLevel(10);
136 l_fname := set_debug_mode('FILE');
137 -- I could not test this, But this is the problem. This should be set after
138 -- set_debug_mode call, other G_FILE will be null
139 OE_DEBUG_PUB.G_DIR := ASO_DEBUG_PUB.G_DIR;
140 OE_DEBUG_PUB.G_FILE := ASO_DEBUG_PUB.G_FILE;
141 utl_file.put_line(G_FILE_PTR, 'Hello Sir, U have Opened a New Session');
142 else
143 ASO_DEBUG_PUB.G_FILE := 'OFF';
144 return;
145 end if;
146 end if;
147
148
149 if G_Debug_Level > 0 then
150 /*
151 if NOT ISDebugOn then
152 if nvl(fnd_profile.value('CONC_REQUEST_ID'),0) <> 0 then
153 l_fname := set_debug_mode('CONC');
154 else
155 l_fname := set_debug_mode('FILE');
156 end if;
157 end if;
158 */ -- Commented OUT for bug 1990541.
159
160 if (G_Debug_Level >= debug_level) then
161 if (ISDebugOn) then
162 if debug_msg is not null then
163 if G_DEBUG_MODE = 'TABLE' then
164 -- Increment Debug count
165 G_Debug_count := G_debug_count + 1;
166 -- Write Debug.
167 G_Debug_tbl(G_debug_count) := substr(debug_msg,1,G_DEBUG_LEN);
168 elsif G_DEBUG_MODE = 'CONC' then /* Concurrent program mode.
169 Write to the table, concurrent pgm output file and
170 also to the debug log file */
171 G_Debug_count := G_debug_count + 1;
172 G_Debug_tbl(G_debug_count) := substr(debug_msg,1,G_DEBUG_LEN);
173 FND_FILE.put_line(FND_FILE.LOG, debug_msg);
174 if G_FILE is not null then
175 utl_file.put_line(G_FILE_PTR, debug_msg);
176 utl_file.fflush(G_FILE_PTR);
177 end if;
178 else -- debug mode
179 if print_date = 'Y' then
180 --utl_file.put_line(G_FILE_PTR, debug_msg ||' ' || to_char( sysdate, 'DD-MON-YYYY HH:MI:SS' ) );
181 utl_file.put_line(G_FILE_PTR, to_char( sysdate,'DD-MON-YYYY HH:MI:SS') || ' ASO ' || debug_msg );
182 utl_file.fflush(G_FILE_PTR);
183 else
184 --utl_file.put_line(G_FILE_PTR, debug_msg);
185 utl_file.put_line(G_FILE_PTR, 'ASO ' || debug_msg );
186 utl_file.fflush(G_FILE_PTR);
187 end if;
188 end if;
189 end if; -- debug_msg is not null
190 end if; -- debug on
191 end if;-- debug level is big enough
192 end if;
193
194 EXCEPTION
195 WHEN OTHERS then
196 if g_debug_mode IN ('TABLE','CONC') then
197 G_DEBUG_COUNT := G_DEBUG_COUNT - 1;
198 end if;
199 debug_off; -- Internal exception turn the debug off
200
201 END add;
202
203
204 Procedure GetFirst(Debug_msg OUT NOCOPY /* file.sql.39 change */ Varchar2)
205 IS
206 BEGIN
207 resetindex;
208 if G_DEBUG_COUNT <> 0 then
209 debug_msg := G_DEbug_tbl(1);
210 g_debug_index := 1;
211 else
212 debug_msg := null;
213 end if;
214 Exception when others then
215 debug_msg := null;
216 END GetFirst;
217
218
219 Procedure GetNext(debug_msg OUT NOCOPY /* file.sql.39 change */ varchar2) is
220 Begin
221 if g_debug_count > g_debug_index then
222 g_debug_index := g_debug_index + 1;
223 debug_msg := G_Debug_tbl(g_debug_index);
224 else
225 debug_msg := null;
226 end if;
227 Exception when others then
228 debug_msg := null;
229 End GetNext;
230
231
232 Function ISLastMsg
233 return number is
234 Begin
235 if g_debug_count <= g_debug_index then
236 return(1);
237 else
238 return(0);
239 end if;
240 End ISLastMsg;
241
242
243 PROCEDURE DumpDebug
244 IS
245 i number := 0;
246 BEGIN
247 --dbms_output.enable(100000);
248 for i in 1..g_debug_count loop
249 --dbms_output.put_line('Number : '|| to_char(i) || ' :: ' ||
250 --G_debug_tbl(i));
251 null;
252 end loop;
253 END DumpDebug;
254
255
256 Procedure GetNextBuffer(p_debug_msg IN OUT NOCOPY /* file.sql.39 change */ varchar2) is
257 msg_str varchar2(500);
258 i number;
259 x_buffer_len number := 0;
260 x_msg_len number := 0;
261 x_prev_index number;
262 x_msg_count number := 1;
263 begin
264 p_debug_msg := '';
265 if G_DEBUG_COUNT > 0 and g_debug_index < g_debug_count then
266 loop
267 x_prev_index := g_debug_index;
268 x_msg_len := length(G_DEbug_tbl(g_debug_index+1));
269 if (x_buffer_len + x_msg_len) < 2000 and x_msg_count <40 then
270 g_debug_index := g_debug_index + 1;
271 x_msg_count := x_msg_count + 1;
272 p_debug_msg := p_debug_msg || fnd_global.local_chr(10) || G_DEBUG_TBL(g_debug_index);
273 x_buffer_len := x_buffer_len + x_msg_len;
274 else
275 exit;
276 end if;
277 if (g_debug_index >= g_debug_count) or x_prev_index = g_debug_index then
278 exit;
279 end if;
280 end loop;
281 end if;
282 end;
283
284
285 Procedure ResetIndex is
286 begin
287 g_debug_index := 0;
288 end;
289
290
291 Procedure SetDebugLevel(p_debug_level in number)
292 IS
293 Begin
294 ASO_DEBUG_PUB.G_DEBUG_LEVEL := p_debug_level;
295 OE_DEBUG_PUB.G_DEBUG_LEVEL := p_debug_level;
296 End SetDebugLevel;
297
298 procedure disable_debug_pvt is
299 begin
300 ASO_DEBUG_PUB.Debug_off;
301 ASO_DEBUG_PUB.G_FILE := null;
302 OE_DEBUG_PUB.Debug_off;
303 OE_DEBUG_PUB.G_FILE := null;
304 If utl_file.is_Open(ASO_DEBUG_PUB.G_FILE_PTR) Then
305 utl_file.fclose(ASO_DEBUG_PUB.G_FILE_PTR);
306 End If;
307 exception
308 When Others Then
309 null;
310 end;
311
312 END ASO_DEBUG_PUB;