[Home] [Help]
PACKAGE BODY: APPS.FA_DEBUG_PKG
Source
1 PACKAGE BODY FA_DEBUG_PKG as
2 /* $Header: FADEBUGB.pls 120.7 2010/02/05 09:28:46 spooyath ship $ */
3
4 -- GLOBAL VARIABLES
5 --
6 -- Debug_Rec_Type : Record to store debug messages
7 --
8 -- fname : calling function name
9 --
10 -- data : debug message
11 --
12
13 g_log_statement_level CONSTANT NUMBER := FND_LOG.LEVEL_STATEMENT;
14 g_log_procedure_level CONSTANT NUMBER := FND_LOG.LEVEL_PROCEDURE;
15 g_log_event_level CONSTANT NUMBER := FND_LOG.LEVEL_EVENT ;
16 g_log_exception_level CONSTANT NUMBER := FND_LOG.LEVEL_EXCEPTION;
17 g_log_error_level CONSTANT NUMBER := FND_LOG.LEVEL_ERROR;
18 g_log_unexpected_level CONSTANT NUMBER := FND_LOG.LEVEL_UNEXPECTED;
19 g_log_runtime_level NUMBER := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
20
21 g_calling_routine varchar2(150);
22 g_release number := fa_cache_pkg.fazarel_release;
23
24 TYPE Debug_Rec_Type IS RECORD
25 ( fname VARCHAR2(30) := NULL,
26 data VARCHAR2(225) := NULL
27 );
28
29 -- Debug_Tbl_Type : A global table to store all debug messages
30 --
31 TYPE Debug_Tbl_Type IS TABLE OF Debug_Rec_Type
32 INDEX BY BINARY_INTEGER;
33
34 FA_DEBUG_TABLE Debug_Tbl_Type;
35
36 -- Index used to keep track of the last fetched
37
38 FA_DEBUG_INDEX NUMBER := 0;
39
40 -- Global variable holding the message count
41
42 FA_DEBUG_COUNT NUMBER := 0;
43
44 -- Global variable holding debug flag
45
46 FA_DEBUG_FLAG varchar2(3) := 'NO';
47 FA_DEBUG_FILE varchar2(3) := 'NO';
48
49 g_print_debug boolean := fa_cache_pkg.fa_print_debug;
50
51 -- Procedure Initialize
52 --
53 -- Usage Used by server program to intialize the global
54 -- debug message table and set the debug flag
55 --
56
57 PROCEDURE Initialize IS
58
59 l_request_id NUMBER;
60 l_dir VARCHAR2(200);
61 l_file VARCHAR2(200);
62 l_dirfile VARCHAR2(200);
63
64 BEGIN
65
66 --if fnd_profile.value('PRINT_DEBUG') = 'Y' then
67 if (g_print_debug) then
68 FA_DEBUG_FLAG := 'YES';
69 end if;
70
71 FA_DEBUG_TABLE.DELETE;
72 FA_DEBUG_COUNT := 0;
73 FA_DEBUG_INDEX := 0;
74
75 --
76 -- Initialization for debugging to a file
77 --
78 if fa_debug_flag <> 'YES' then
79 -- File Debugging should only be enabled if PRINT_DEBUG is also enabled
80 fa_debug_file := 'NO';
81
82 elsif fa_debug_file <> 'YES' then
83 -- Also, only initialize file debugging once
84
85 l_dirfile := fa_cache_pkg.fa_debug_file;
86 if l_dirfile is not null then
87
88 -- Do not set up file/dir info if this is a concurrent program
89 -- FND_FILE will automatically place the debug messages to
90 -- the concurrent program's log file.
91 --l_request_id := to_number(fnd_profile.value('CONC_REQUEST_ID'));
92 l_request_id := fnd_global.conc_request_id;
93
94 if l_request_id is null or l_request_id <= 0 then
95 l_dir := substr(l_dirfile, 1, instr(l_dirfile, ' ')-1);
96 l_file := substr(l_dirfile, instr(l_dirfile, ' ')+1);
97 if l_dir is not null and l_file is not null then
98 fnd_file.put_names(l_file||'.log', l_file||'.out', l_dir);
99 end if;
100 end if;
101
102 fa_debug_file := 'YES';
103 fnd_file.put_line(fnd_file.log, 'Starting debug session....');
104
105 end if;
106 end if;
107 END Initialize;
108
109
110 -- Function Print_Debug
111 --
112 -- Usage Used by server program to check the debug flag
113 --
114
115 FUNCTION Print_Debug RETURN BOOLEAN IS
116 BEGIN
117
118 return (FA_DEBUG_FLAG = 'YES');
119
120 END Print_Debug;
121
122
123 -- Procedure Add
124 --
125 -- Usage Used by server programs to add debug message to
126 -- debug message table
127 --
128 -- Desc This procedure is oeverloaded.
129 -- There are four datatypes differing in Value parameter:
130 -- Base :
131 -- Value VARCHAR2
132 -- first overloaded procedure :
133 -- Value NUMBER
134 -- second overloaded procedure :
135 -- Value DATE
136 -- fourth overloaded procedure :
137 -- Value BOOLEAN
138 --
139 PROCEDURE Add
140 ( fname in varchar2,
141 element in varchar2,
142 value in varchar2,
143 p_log_level_rec IN FA_API_TYPES.log_level_rec_type default null) IS
144
145 debug_str varchar2(225);
146
147 BEGIN
148
149 debug_str := substr(element, 1, 150) || ' has the value of ' ||
150 substr(value, 1, 54);
151
152 if (g_release = 11) then
153
154 FA_DEBUG_COUNT := FA_DEBUG_COUNT + 1;
155 FA_DEBUG_TABLE(FA_DEBUG_COUNT).fname := substr(fname, 1, 30);
156 FA_DEBUG_TABLE(FA_DEBUG_COUNT).data := debug_str;
157
158 -- Bug 9349372 : fa_debug_table is populated only for 11i
159 if fa_debug_file = 'YES' then
160 fnd_file.put_line(fnd_file.Log,
161 fa_debug_table(fa_debug_count).fname || ': '||
162 fa_debug_table(fa_debug_count).data);
163 end if;
164
165 else
166
167 g_calling_routine := 'FA.PLSQL.'||fname;
168 if (g_log_statement_level >= g_log_runtime_level) then
169 FND_LOG.STRING(FND_LOG.LEVEL_STATEMENT , g_calling_routine, debug_str);
170 end if;
171
172 end if;
173
174
175 EXCEPTION
176 when fnd_file.utl_file_error then
177 fa_debug_file := 'NO';
178 END Add;
179
180
181 PROCEDURE Add
182 ( fname in varchar2,
183 element in varchar2,
184 value in number,
185 p_log_level_rec IN FA_API_TYPES.log_level_rec_type default null) IS
186
187 debug_str varchar2(225);
188
189 BEGIN
190
191 debug_str := substr(element, 1, 150) || ' has the value of ' ||
192 substr(to_char(value), 1, 54);
193
194 if (g_release = 11) then
195
196 FA_DEBUG_COUNT := FA_DEBUG_COUNT + 1;
197 FA_DEBUG_TABLE(FA_DEBUG_COUNT).fname := substr(fname, 1, 30);
198 FA_DEBUG_TABLE(FA_DEBUG_COUNT).data := debug_str;
199
200 -- Bug 9349372 : fa_debug_table is populated only for 11i
201 if fa_debug_file = 'YES' then
202 fnd_file.put_line(fnd_file.Log,
203 fa_debug_table(fa_debug_count).fname || ': '||
204 fa_debug_table(fa_debug_count).data);
205 end if;
206
207 else
208
209 g_calling_routine := 'FA.PLSQL.'||fname;
210 if (g_log_statement_level >= g_log_runtime_level) then
211 FND_LOG.STRING(FND_LOG.LEVEL_STATEMENT , g_calling_routine, debug_str);
212 end if;
213
214 end if;
215
216 EXCEPTION
217 when fnd_file.utl_file_error then
218 fa_debug_file := 'NO';
219
220 END Add;
221
222
223 PROCEDURE Add
224 ( fname in varchar2,
225 element in varchar2,
226 value in date,
227 p_log_level_rec IN FA_API_TYPES.log_level_rec_type default null) IS
228
229 debug_str varchar2(225);
230
231 BEGIN
232
233 debug_str := substr(element, 1, 150) || ' has the value of ' ||
234 to_char(value, 'DD-MM-YYYY HH24:MI:SS');
235
236
237 if (g_release = 11) then
238
239 FA_DEBUG_COUNT := FA_DEBUG_COUNT + 1;
240 FA_DEBUG_TABLE(FA_DEBUG_COUNT).fname := substr(fname, 1, 30);
241 FA_DEBUG_TABLE(FA_DEBUG_COUNT).data := debug_str;
242
243 -- Bug 9349372 : fa_debug_table is populated only for 11i
244 if fa_debug_file = 'YES' then
245 fnd_file.put_line(fnd_file.Log,
246 fa_debug_table(fa_debug_count).fname || ': '||
247 fa_debug_table(fa_debug_count).data);
248 end if;
249
250 else
251
252 g_calling_routine := 'FA.PLSQL.'||fname;
253 if (g_log_statement_level >= g_log_runtime_level) then
254 FND_LOG.STRING(FND_LOG.LEVEL_STATEMENT , g_calling_routine, debug_str);
255 end if;
256
257 end if;
258
259 EXCEPTION
260 when fnd_file.utl_file_error then
261 fa_debug_file := 'NO';
262
263 END Add;
264
265
266 PROCEDURE Add
267 ( fname in varchar2,
268 element in varchar2,
269 value in boolean,
270 p_log_level_rec IN FA_API_TYPES.log_level_rec_type default null) IS
271
272 debug_str varchar2(225);
273 l_value varchar2(5);
274
275 BEGIN
276
277 if (value) then
278 l_value := 'TRUE';
279 else
280 l_value := 'FALSE';
281 end if;
282
283 debug_str := substr(element, 1, 150) || ' has the value of ' || l_value;
284
285 if (g_release = 11) then
286
287 FA_DEBUG_COUNT := FA_DEBUG_COUNT + 1;
288 FA_DEBUG_TABLE(FA_DEBUG_COUNT).fname := substr(fname, 1, 30);
289 FA_DEBUG_TABLE(FA_DEBUG_COUNT).data := debug_str;
290
291 -- Bug 9349372 : fa_debug_table is populated only for 11i
292 if fa_debug_file = 'YES' then
293 fnd_file.put_line(fnd_file.Log,
294 fa_debug_table(fa_debug_count).fname || ': '||
295 fa_debug_table(fa_debug_count).data);
296 end if;
297
298 else
299
300 g_calling_routine := 'FA.PLSQL.'||fname;
301 if (g_log_statement_level >= g_log_runtime_level) then
302 FND_LOG.STRING(FND_LOG.LEVEL_STATEMENT , g_calling_routine, debug_str);
303 end if;
304
305 end if;
306
307 EXCEPTION
308 when fnd_file.utl_file_error then
309 fa_debug_file := 'NO';
310
311 END Add;
312
313
314 -- Procedure Get_Debug_Messages
315 --
316 -- Usage Used by client program to get debug messages from debug
317 -- table
318 --
319 PROCEDURE Get_Debug_Messages
320 ( d_mesg1 out nocopy varchar2,
321 d_mesg2 out nocopy varchar2,
322 d_mesg3 out nocopy varchar2,
323 d_mesg4 out nocopy varchar2,
324 d_mesg5 out nocopy varchar2,
325 d_mesg6 out nocopy varchar2,
326 d_mesg7 out nocopy varchar2,
327 d_mesg8 out nocopy varchar2,
328 d_mesg9 out nocopy varchar2,
329 d_mesg10 out nocopy varchar2,
330 d_more_mesgs out nocopy boolean
331 , p_log_level_rec IN FA_API_TYPES.log_level_rec_type default null) IS
332
333 l_temp_str varchar2(255) := NULL;
334 l_more_mesgs boolean := TRUE;
335 l_index number;
336
337 BEGIN
338
339
340 d_mesg1 := NULL;
341 d_mesg2 := NULL;
342 d_mesg3 := NULL;
343 d_mesg4 := NULL;
344 d_mesg5 := NULL;
345 d_mesg6 := NULL;
346 d_mesg7 := NULL;
347 d_mesg8 := NULL;
348 d_mesg9 := NULL;
349 d_mesg10 := NULL;
350 d_more_mesgs := TRUE;
351
352 IF (FA_DEBUG_INDEX >= FA_DEBUG_COUNT) THEN
353 d_more_mesgs := FALSE;
354 RETURN;
355 END IF;
356
357 WHILE l_more_mesgs LOOP
358
359 FA_DEBUG_INDEX := FA_DEBUG_INDEX + 1;
360
361 if (FA_DEBUG_INDEX > FA_DEBUG_COUNT) then
362 l_more_mesgs := FALSE;
363 EXIT;
364 else
365
366 l_temp_str := FA_DEBUG_TABLE(FA_DEBUG_INDEX).fname ;
367 l_temp_str := FA_DEBUG_TABLE(FA_DEBUG_INDEX).data;
368
369 l_temp_str := FA_DEBUG_TABLE(FA_DEBUG_INDEX).fname || ': ' ||
370 FA_DEBUG_TABLE(FA_DEBUG_INDEX).data;
371
372 l_index := mod(FA_DEBUG_INDEX, 10);
373
374 if (l_index = 1) then
375 d_mesg1 := l_temp_str;
376 elsif (l_index = 2) then
377 d_mesg2 := l_temp_str;
378 elsif (l_index = 3) then
379 d_mesg3 := l_temp_str;
380 elsif (l_index = 4) then
381 d_mesg4 := l_temp_str;
382 elsif (l_index = 5) then
383 d_mesg5 := l_temp_str;
384 elsif (l_index = 6) then
385 d_mesg6 := l_temp_str;
386 elsif (l_index = 7) then
387 d_mesg7 := l_temp_str;
388 elsif (l_index = 8) then
389 d_mesg8 := l_temp_str;
390 elsif (l_index = 9) then
391 d_mesg9 := l_temp_str;
392 else
393 d_mesg10 := l_temp_str;
394 l_more_mesgs := FALSE;
395 end if;
396 end if;
397 END LOOP;
398
399 if (FA_DEBUG_INDEX >= FA_DEBUG_COUNT) then
400 d_more_mesgs := FALSE;
401 end if;
402
403 EXCEPTION
404 WHEN OTHERS THEN
405
406 FA_DEBUG_TABLE.DELETE;
407 FA_DEBUG_COUNT := 0;
408 FA_DEBUG_INDEX := 0;
409 d_mesg1 := 'Database Error: ' || SQLERRM;
410 d_more_mesgs := FALSE;
411
412 END Get_Debug_Messages;
413
414
415 -- Procedure Set_Debug_Flag
416 --
417 -- Usage Used by internal deveoplers to set the debug flag
418 -- to 'YES'
419 --
420 PROCEDURE Set_Debug_Flag
421 ( debug_flag in varchar2 := 'YES'
422 , p_log_level_rec IN FA_API_TYPES.log_level_rec_type default null) IS
423 BEGIN
424
425 FA_DEBUG_FLAG := debug_flag;
426 FA_DEBUG_TABLE.DELETE;
427 FA_DEBUG_COUNT := 0;
428 FA_DEBUG_INDEX := 0;
429
430 if FA_DEBUG_FLAG = 'NO' then
431 FA_DEBUG_FILE := 'NO';
432 end if;
433
434 END Set_Debug_Flag;
435
436
437 -- Procedure Reset_Index
438 --
439 -- Usage Used by internal developer to move the index
440 -- of debug table
441 --
442 PROCEDURE Reset_Index
443 ( d_index in number
444 , p_log_level_rec IN FA_API_TYPES.log_level_rec_type default null) IS
445 BEGIN
446 if (d_index is null) then
447 FA_DEBUG_INDEX := 0;
448 else
449 FA_DEBUG_INDEX := d_index;
450 end if;
451
452 END Reset_Index;
453
454
455 -- Procedure Dump_Debug_Messages
456 --
457 -- Usage Used by internal developers to print all messages
458 -- of debug table
459 --
460 PROCEDURE Dump_Debug_Messages
461 ( target_str in varchar2
462 , p_log_level_rec IN FA_API_TYPES.log_level_rec_type default null) IS
463 t_count number;
464 BEGIN
465 t_count := FA_DEBUG_TABLE.count;
466 --dbms_output.put_line('Dumping Debug Messages :');
467 --dbms_output.put_line('FA_DEBUG_COUNT = ' || to_char(FA_DEBUG_COUNT));
468 --dbms_output.put_line('FA_DEBUG_INDEX = ' || to_char(FA_DEBUG_INDEX));
469 /*
470 if (target_str is null) then
471
472 FOR I IN 1..FA_DEBUG_COUNT LOOP
473 dbms_output.put_line( FA_DEBUG_TABLE(I).fname || ': ' ||
474 FA_DEBUG_TABLE(I).data);
475 END LOOP;
476
477 end if;
478 */
479 EXCEPTION
480 WHEN OTHERS THEN
481 --dbms_output.put_line('Dump_Debug_Messages : Error - ' || SQLERRM);
482 null;
483 END Dump_Debug_Messages;
484
485
486 PROCEDURE Dump_Debug_Messages
487 ( max_mesgs in number := NULL, p_log_level_rec IN FA_API_TYPES.log_level_rec_type default null) IS
488
489 l_debug_msg1 varchar2(255);
490 l_debug_msg2 varchar2(255);
491 l_debug_msg3 varchar2(255);
492 l_debug_msg4 varchar2(255);
493 l_debug_msg5 varchar2(255);
494 l_debug_msg6 varchar2(255);
495 l_debug_msg7 varchar2(255);
496 l_debug_msg8 varchar2(255);
497 l_debug_msg9 varchar2(255);
498 l_debug_msg10 varchar2(255);
499 l_more_debug_msgs boolean;
500
501 BEGIN
502
503 fnd_message.set_name('OFA', 'FA_SHARED_DEBUG');
504 fnd_message.set_token('INFO', 'Debug');
505 fnd_msg_pub.add;
506
507
508 loop
509
510 fa_debug_pkg.Get_Debug_Messages
511 (d_mesg1 => l_debug_msg1,
512 d_mesg2 => l_debug_msg2,
513 d_mesg3 => l_debug_msg3,
514 d_mesg4 => l_debug_msg4,
515 d_mesg5 => l_debug_msg5,
516 d_mesg6 => l_debug_msg6,
517 d_mesg7 => l_debug_msg7,
518 d_mesg8 => l_debug_msg8,
519 d_mesg9 => l_debug_msg9,
520 d_mesg10 => l_debug_msg10,
521 d_more_mesgs => l_more_debug_msgs, p_log_level_rec => p_log_level_rec);
522
523
524 fnd_message.set_name('OFA', 'FA_SRVR_MESSAGE_1');
525 fnd_message.set_token('MSG1', l_debug_msg1);
526 fnd_msg_pub.add;
527
528 if l_debug_msg2 is not null then
529 fnd_message.set_name('OFA', 'FA_SRVR_MESSAGE_1');
530 fnd_message.set_token('MSG1', l_debug_msg2);
531 fnd_msg_pub.add;
532 end if;
533 if l_debug_msg3 is not null then
534 fnd_message.set_name('OFA', 'FA_SRVR_MESSAGE_1');
535 fnd_message.set_token('MSG1', l_debug_msg3);
536 fnd_msg_pub.add;
537 end if;
538 if l_debug_msg4 is not null then
539 fnd_message.set_name('OFA', 'FA_SRVR_MESSAGE_1');
540 fnd_message.set_token('MSG1', l_debug_msg4);
541 fnd_msg_pub.add;
542 end if;
543 if l_debug_msg5 is not null then
544 fnd_message.set_name('OFA', 'FA_SRVR_MESSAGE_1');
545 fnd_message.set_token('MSG1', l_debug_msg5);
546 fnd_msg_pub.add;
547 end if;
548 if l_debug_msg6 is not null then
549 fnd_message.set_name('OFA', 'FA_SRVR_MESSAGE_1');
550 fnd_message.set_token('MSG1', l_debug_msg6);
551 fnd_msg_pub.add;
552 end if;
553 if l_debug_msg7 is not null then
554 fnd_message.set_name('OFA', 'FA_SRVR_MESSAGE_1');
555 fnd_message.set_token('MSG1', l_debug_msg7);
556 fnd_msg_pub.add;
557 end if;
558 if l_debug_msg8 is not null then
559 fnd_message.set_name('OFA', 'FA_SRVR_MESSAGE_1');
560 fnd_message.set_token('MSG1', l_debug_msg8);
561 fnd_msg_pub.add;
562 end if;
563 if l_debug_msg9 is not null then
564 fnd_message.set_name('OFA', 'FA_SRVR_MESSAGE_1');
565 fnd_message.set_token('MSG1', l_debug_msg9);
566 fnd_msg_pub.add;
567 end if;
568 if l_debug_msg10 is not null then
569 fnd_message.set_name('OFA', 'FA_SRVR_MESSAGE_1');
570 fnd_message.set_token('MSG1', l_debug_msg10);
571 fnd_msg_pub.add;
572 end if;
573
574 if not l_more_debug_msgs then
575 exit;
576 end if;
577
578 end loop;
579
580 EXCEPTION
581 when others then
582 null;
583
584 END Dump_Debug_messages;
585
586 -- Procedure Write_Debug_Log
587 --
588 PROCEDURE Write_Debug_Log
589 IS
590 l_debug_str varchar2(255) := NULL;
591 BEGIN
592 if (FA_DEBUG_COUNT > 0) then
593 for i in 1..(FA_DEBUG_COUNT) loop
594 l_debug_str := FA_DEBUG_TABLE(i).fname||':'||
595 FA_DEBUG_TABLE(i).data;
596 fa_rx_conc_mesg_pkg.log(l_debug_str);
597 end loop;
598 end if;
599 END Write_Debug_Log;
600
601
602 END FA_DEBUG_PKG;