1 PACKAGE BODY BIS_DEBUG_LOG AS
2 /* $Header: BISDLOGB.pls 120.2 2005/06/29 06:57:05 aguwalan noship $ */
3 g_module VARCHAR2(200) := get_bis_schema_name ||'.BIS_DEBUG_LOG';
4
5 -- ------------------------
6 -- Public Procedures
7 -- ------------------------
8 PROCEDURE setup_file(
9 p_log_file VARCHAR2,
10 p_out_file VARCHAR2,
11 p_directory VARCHAR2) is
12 l_dir varchar2(300);
13 Begin
14 g_module := get_bis_schema_name || '.' || NVL(p_log_file, 'BIS_DEBUG_LOG');
15 l_dir:=p_directory;
16 if l_dir is null then
17 l_dir:=fnd_profile.value('UTL_FILE_LOG');
18 if l_dir is null then
19 l_dir:='/sqlcom/log';
20 end if;
21 end if;
22 FND_FILE.PUT_NAMES(p_log_file,p_out_file,l_dir);
23
24 --if fnd_profile.value('EDW_DEBUG')='Y' or
25 -- FND_LOG.G_CURRENT_RUNTIME_LEVEL=FND_LOG.LEVEL_STATEMENT
26 if FND_LOG.TEST( FND_LOG.LEVEL_STATEMENT , g_module ) then
27 g_debug:=true;
28 else
29 g_debug:=false;
30 end if;
31 Exception when others then
32 raise;
33 End;
34
35 procedure set_debug is
36 Begin
37 g_debug:=true;
38 Exception when others then
39 raise;
40 End;
41
42 procedure unset_debug is
43 Begin
44 g_debug:=false;
45 Exception when others then
46 raise;
47 End;
48
49 Procedure close is
50 Begin
51 FND_FILE.close;
52 Exception when others then
53 raise;
54 End;
55
56 PROCEDURE debug_line(p_text VARCHAR2) is
57 Begin
58 if g_debug then
59 put_line(p_text, FND_LOG.LEVEL_STATEMENT);
60 end if;
61 Exception when others then
62 raise;
63 End;
64
65 /*
66 * Added for FND_LOG uptaking.
67 */
68 PROCEDURE debug_line(p_text VARCHAR2, p_severity NUMBER) is
69 Begin
70 if g_debug then
71 put_line(p_text, p_severity);
72 end if;
73 Exception when others then
74 raise;
75 End;
76
77 PROCEDURE debug(p_text VARCHAR2) is
78 Begin
79 if g_debug then
80 put(p_text, FND_LOG.LEVEL_STATEMENT);
81 end if;
82 Exception when others then
83 raise;
84 End;
85
86 /*
87 * Added for FND_LOG uptaking.
88 */
89 PROCEDURE debug(p_text VARCHAR2, p_severity NUMBER) is
90 Begin
91 if g_debug then
92 put(p_text, p_severity);
93 end if;
94 Exception when others then
95 raise;
96 End;
97
98 PROCEDURE debug_line_n(p_text VARCHAR2) is
99 Begin
100 if g_debug then
101 new_line;
102 put_line(p_text, FND_LOG.LEVEL_STATEMENT);
103 end if;
104 Exception when others then
105 raise;
106 End;
107
108 /*
109 * Added for FND_LOG uptaking.
110 */
111 PROCEDURE debug_line_n(p_text VARCHAR2, p_severity NUMBER) is
112 Begin
113 if g_debug then
114 new_line;
115 put_line(p_text, p_severity);
116 end if;
117 Exception when others then
118 raise;
119 End;
120
121
122 PROCEDURE put_line(p_text VARCHAR2) is
123 Begin
124 put_line(p_text, FND_LOG.LEVEL_EXCEPTION);
125 End;
126
127 /*
128 * Added for FND_LOG uptaking.
129 */
130 PROCEDURE put_line(p_text VARCHAR2, p_severity NUMBER) is
131 l_len number;
132 l_start number:=1;
133 l_end number:=1;
134 last_reached boolean:=false;
135 begin
136 if p_text is null or p_text='' then
137 return;
138 end if;
139 l_len:=nvl(length(p_text),0);
140 if l_len <=0 then
141 return;
142 end if;
143 while true loop
144 l_end:=l_start+250;
145 if l_end >= l_len then
146 l_end:=l_len;
147 last_reached:=true;
148 end if;
149 FND_FILE.PUT_LINE(FND_FILE.LOG,substr(p_text,l_start,250));
150
151 if p_severity >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
152 then
153 FND_LOG.STRING( p_severity, g_module, substr(p_text,l_start,250));
154 end if;
155
156 l_start:=l_start+250;
157 if last_reached then
158 exit;
159 end if;
160 end loop;
161 Exception when others then
162 raise;
163 End;
164
165
166
167 PROCEDURE put(p_text VARCHAR2) is
168 Begin
169 put(p_text, FND_LOG.LEVEL_EXCEPTION);
170 End;
171
172 /*
173 * Added for FND_LOG uptaking.
174 */
175 PROCEDURE put(p_text VARCHAR2, p_severity NUMBER ) is
176 l_len number;
177 l_start number:=1;
178 l_end number:=1;
179 last_reached boolean:=false;
180 begin
181 if p_text is null or p_text='' then
182 return;
183 end if;
184 l_len:=nvl(length(p_text),0);
185 if l_len <=0 then
186 return;
187 end if;
188
189 while true loop
190 l_end:=l_start+250;
191 if l_end >= l_len then
192 l_end:=l_len;
193 last_reached:=true;
194 end if;
195 FND_FILE.PUT(FND_FILE.LOG,substr(p_text,l_start,250));
196
197 if p_severity >= FND_LOG.G_CURRENT_RUNTIME_LEVEL then
198 FND_LOG.STRING( p_severity, g_module, substr(p_text,l_start,250));
199 end if;
200
201 l_start:=l_start+250;
202 if last_reached then
203 exit;
204 end if;
205 end loop;
206 Exception when others then
207 raise;
208 End;
209
210
211
212 PROCEDURE put_line_n(p_text VARCHAR2) is
213 Begin
214 put_line_n(p_text, FND_LOG.LEVEL_EXCEPTION );
215 Exception when others then
216 raise;
217 End;
218
219 /*
220 * Added for FND_LOG uptaking.
221 */
222 PROCEDURE put_line_n(p_text VARCHAR2, p_severity NUMBER) is
223 Begin
224 new_line;
225 put_line(p_text, p_severity);
226 Exception when others then
227 raise;
228 End;
229
230
231 PROCEDURE new_line is
232 Begin
233 put_line(' ');
234 Exception when others then
235 raise;
236 End;
237
238 PROCEDURE put_time is
239 Begin
240 put_line(' '||to_char(sysdate,'MM/DD/YYYY HH24:MI:SS'));
241 Exception when others then
242 raise;
243 End;
244
245 PROCEDURE debug_time is
246 Begin
247 if g_debug then
248 put_line(' '||to_char(sysdate,'MM/DD/YYYY HH24:MI:SS'));
249 end if;
250 Exception when others then
251 raise;
252 End;
253
254 function get_time return date is
255 Begin
256 return sysdate;
257 Exception when others then
258 raise;
259 End;
260
261 PROCEDURE put_out(p_text VARCHAR2) is
262 l_len number;
263 l_start number:=1;
264 l_end number:=1;
265 last_reached boolean:=false;
266 begin
267 if p_text is null or p_text='' then
268 return;
269 end if;
270 l_len:=nvl(length(p_text),0);
271 if l_len <=0 then
272 return;
273 end if;
274 while true loop
275 l_end:=l_start+250;
276 if l_end >= l_len then
277 l_end:=l_len;
278 last_reached:=true;
279 end if;
280 FND_FILE.PUT_LINE(FND_FILE.OUTPUT,substr(p_text,l_start,250));
281 l_start:=l_start+250;
282 if last_reached then
283 exit;
284 end if;
285 end loop;
286 Exception when others then
287 raise;
288 End;
289
290 PROCEDURE put_out_n(p_text VARCHAR2) is
291 Begin
292 put_out(' ');
293 put_out(p_text);
294 Exception when others then
295 raise;
296 End;
297
298 /*
299 function to return BIS schema name
300 */
301 function get_bis_schema_name return varchar2 is
302 l_dummy1 varchar2(2000);
303 l_dummy2 varchar2(2000);
304 l_schema varchar2(400);
305 Begin
306 if FND_INSTALLATION.GET_APP_INFO('BIS',l_dummy1, l_dummy2,l_schema) = false then
307 return null;
308 end if;
309 return l_schema;
310 Exception when others then
311 return null;
312 End;
313 End;