1 package FND_LOG AUTHID CURRENT_USER as
2 /* $Header: AFUTLOGS.pls 120.2.12010000.2 2010/03/12 18:31:55 pferguso ship $ */
3 /* Documentation for this package is at */
4 /* http://www-apps.us.oracle.com/atg/plans/r115/aflog.txt */
5
6 LEVEL_UNEXPECTED CONSTANT NUMBER := 6;
7 LEVEL_ERROR CONSTANT NUMBER := 5;
8 LEVEL_EXCEPTION CONSTANT NUMBER := 4;
9 LEVEL_EVENT CONSTANT NUMBER := 3;
10 LEVEL_PROCEDURE CONSTANT NUMBER := 2;
11 LEVEL_STATEMENT CONSTANT NUMBER := 1;
12
13 /* Context ID of the log transaction */
14 G_TRANSACTION_CONTEXT_ID NUMBER;
15
16 /*
17 ** FND_LOG.INIT_TRANSACTION
18 **
19 ** Description:
20 ** Initializes a log transaction. A log transaction
21 ** corresponds to an instance or invocation of a single
22 ** component. (e.g. A concurrent request, service process,
23 ** open form, ICX function)
24 **
25 ** This routine should be called only after
26 ** FND_GLOBAL.INITIALIZE, since some of the context information
27 ** is retrieved from FND_GLOBAL.
28 **
29 ** Arguments:
30 ** CONC_REQUEST_ID - Concurrent request id
31 ** FORM_ID - Form id
32 ** FORM_APPLICATION_ID - Form application id
33 ** CONCURRENT_PROCESS_ID - Service process id
34 ** CONCURRENT_QUEUE_ID - Service queue id
35 ** QUEUE_APPLICATION_ID - Service queue application id
36 ** SOA_INSTANCE_ID - SOA instance id
37 **
38 ** Use only the arguments that apply to the caller.
39 ** Any argument that does not apply should be passed as NULL
40 ** i.e. when calling from a form, pass in FORM_ID and FORM_APPLICATION_ID
41 ** and leave all other parameters NULL.
42 **
43 ** Returns:
44 ** ID of the log transaction context
45 **
46 */
47 FUNCTION INIT_TRANSACTION (CONC_REQUEST_ID IN NUMBER DEFAULT NULL,
48 FORM_ID IN NUMBER DEFAULT NULL,
49 FORM_APPLICATION_ID IN NUMBER DEFAULT NULL,
50 CONCURRENT_PROCESS_ID IN NUMBER DEFAULT NULL,
51 CONCURRENT_QUEUE_ID IN NUMBER DEFAULT NULL,
52 QUEUE_APPLICATION_ID IN NUMBER DEFAULT NULL,
53 SOA_INSTANCE_ID IN NUMBER DEFAULT NULL)
54 return NUMBER;
55
56
57 /*
58 ** FND_LOG.SET_TRANSACTION
59 ** Description:
60 ** Sets the log transaction ID for the current DB connection.
61 ** This routine should be used whenever the database connection
62 ** changes within the context of a transaction. For example, this
63 ** routine will be used for successive hits within the same ICX
64 ** transaction or when a concurrent process reconnects to the database.
65 **
66 ** Arguments:
67 ** Log_Transaction
68 **
69 */
70 PROCEDURE SET_TRANSACTION (TRANS_CONTEXT_ID IN NUMBER);
71
72 /*
73 ** Writes the message to the log file for the spec'd level and module
74 ** if logging is enabled for this level and module
75 */
76 PROCEDURE STRING(LOG_LEVEL IN NUMBER,
77 MODULE IN VARCHAR2,
78 MESSAGE IN VARCHAR2);
79
80 /*
81 ** Writes the message with context information to the log file for
82 ** the spec'd level and module if logging is enabled for this level
83 ** and module
84 */
85 PROCEDURE STRING_WITH_CONTEXT(LOG_LEVEL IN NUMBER,
86 MODULE IN VARCHAR2,
87 MESSAGE IN VARCHAR2,
88 ENCODED IN VARCHAR2 DEFAULT NULL,
89 NODE IN VARCHAR2 DEFAULT NULL,
90 NODE_IP_ADDRESS IN VARCHAR2 DEFAULT NULL,
91 PROCESS_ID IN VARCHAR2 DEFAULT NULL,
92 JVM_ID IN VARCHAR2 DEFAULT NULL,
93 THREAD_ID IN VARCHAR2 DEFAULT NULL,
94 AUDSID IN NUMBER DEFAULT NULL,
95 DB_INSTANCE IN NUMBER DEFAULT NULL);
96
97 /*
98 ** Writes a message to the log file if this level and module is enabled
99 ** The message gets set previously with FND_MESSAGE.SET_NAME,
100 ** SET_TOKEN, etc.
101 ** The message is popped off the message dictionary stack, if POP_MESSAGE
102 ** is TRUE. Pass FALSE for POP_MESSAGE if the message will also be
103 ** displayed to the user later.
104 ** Example usage:
105 ** FND_MESSAGE.SET_NAME(...); -- Set message
106 ** FND_MESSAGE.SET_TOKEN(...); -- Set token in message
107 ** FND_LOG.MESSAGE(..., FALSE); -- Log message
108 ** FND_MESSAGE.ERROR; -- Display message
109 */
110 PROCEDURE MESSAGE(LOG_LEVEL IN NUMBER,
111 MODULE IN VARCHAR2,
112 POP_MESSAGE IN BOOLEAN DEFAULT NULL);
113
114 /*
115 ** Writes a message to the log file if this level and module is enabled
116 ** The message gets set previously with FND_MESSAGE.SET_NAME,
117 ** SET_TOKEN, etc.
118 ** The message is popped off the message dictionary stack, if POP_MESSAGE
119 ** is TRUE. Pass FALSE for POP_MESSAGE if the message will also be
120 ** displayed to the user later.
121 ** Example usage:
122 ** FND_MESSAGE.SET_NAME(...); -- Set message
123 ** FND_MESSAGE.SET_TOKEN(...); -- Set token in message
124 ** ATTACHMENT_ID := FND_LOG.MESSAGE_WITH_ATTACHMENT(..., FALSE); -- Log message
125 ** -- For ASCII data use WRITE
126 ** FND_LOG_ATTACHMENT.WRITE(ATTACHMENT_ID, ...);
127 ** -- For Non-ASCII data use WRITE_RAW
128 ** FND_LOG_ATTACHMENT.WRITE_RAW(ATTACHMENT_ID, ...);
129 ** FND_LOG_ATTACHMENT.CLOSE();
130 */
131 FUNCTION MESSAGE_WITH_ATTACHMENT(LOG_LEVEL IN NUMBER,
132 MODULE IN VARCHAR2,
133 POP_MESSAGE IN BOOLEAN DEFAULT NULL,
134 P_CHARSET IN VARCHAR2 DEFAULT 'ascii',
135 P_MIMETYPE IN VARCHAR2 DEFAULT 'text/html',
136 P_ENCODING IN VARCHAR2 DEFAULT NULL,
137 P_LANG IN VARCHAR2 DEFAULT NULL,
138 P_FILE_EXTN IN VARCHAR2 DEFAULT 'txt',
139 P_DESC IN VARCHAR2 DEFAULT NULL) RETURN NUMBER;
140
141 /*
142 ** Writes a message to the log file if this level and module is enabled
143 ** The message gets set previously with FND_MESSAGE.SET_NAME,
144 ** SET_TOKEN, etc.
145 ** The message is popped off the message dictionary stack, if POP_MESSAGE
146 ** is TRUE. Pass FALSE for POP_MESSAGE if the message will also be
147 ** displayed to the user later.
148 ** Example usage:
149 ** FND_MESSAGE.SET_NAME(...); -- Set message
150 ** FND_MESSAGE.SET_TOKEN(...); -- Set token in message
151 ** FND_LOG.MESSAGE(..., FALSE); -- Log message
152 ** FND_MESSAGE.ERROR; -- Display message
153 */
154 PROCEDURE MESSAGE(LOG_LEVEL IN NUMBER,
155 MODULE IN VARCHAR2,
156 POP_MESSAGE IN BOOLEAN DEFAULT NULL,
157 AUTO_LOG IN VARCHAR2);
158
159 /*
160 ** Writes a message with context to the log file if this level and
161 ** module is enabled. This requires that the message was set
162 ** previously with FND_MESSAGE.SET_NAME, SET_TOKEN, etc.
163 ** The message is popped off the message dictionary stack, if POP_MESSAGE
164 ** is TRUE. Pass FALSE for POP_MESSAGE if the message will also be
165 ** displayed to the user later. If POP_MESSAGE isn't passed, the
166 ** message will not be popped off the stack, so it must be displayed
167 ** or explicitly cleared later on.
168 */
169 PROCEDURE MESSAGE_WITH_CONTEXT(LOG_LEVEL IN NUMBER,
170 MODULE IN VARCHAR2,
171 POP_MESSAGE IN BOOLEAN DEFAULT NULL, --Default FALSE
172 NODE IN VARCHAR2 DEFAULT NULL,
173 NODE_IP_ADDRESS IN VARCHAR2 DEFAULT NULL,
174 PROCESS_ID IN VARCHAR2 DEFAULT NULL,
175 JVM_ID IN VARCHAR2 DEFAULT NULL,
176 THREAD_ID IN VARCHAR2 DEFAULT NULL,
177 AUDSID IN NUMBER DEFAULT NULL,
178 DB_INSTANCE IN NUMBER DEFAULT NULL);
179
180 /*
181 ** FND_LOG.WORK_METRIC
182 ** Description:
183 ** Writes a metric value out to the FND tables in an
184 ** autonomous transaction. Posting to the Business Event
185 ** system is deferred until WORK_METRICS_EVENT is called.
186 **
187 ** Arguments:
188 ** Module - Module name (See FND_LOG standards.)
189 ** Metric_code - Internal name of metric.
190 ** Metric_value - Value for metric (string, number, or date)
191 **
192 */
193 procedure WORK_METRIC (MODULE IN VARCHAR2,
194 METRIC_CODE IN VARCHAR2,
195 METRIC_VALUE IN VARCHAR2);
196
197 procedure WORK_METRIC (MODULE IN VARCHAR2,
198 METRIC_CODE IN VARCHAR2,
199 METRIC_VALUE IN NUMBER);
200
201 procedure WORK_METRIC (MODULE IN VARCHAR2,
202 METRIC_CODE IN VARCHAR2,
203 METRIC_VALUE IN DATE);
204
205 /*
206 ** FND_LOG.WORK_METRICS_EVENT
207 ** Description:
208 ** Posts the pending metrics for the current component
209 ** session to the Business Event system and updates the pending
210 ** metrics with the event key. The metrics will be bundled in an
211 ** XML message included in the event. The event will be named:
212 ** "oracle.apps.fnd.system.metrics"
213 **
214 ** Arguments:
215 ** CONTEXT_ID ID of the context to post the metrics event for.
216 ** Use NULL for the current context.
217 */
218
219 PROCEDURE WORK_METRICS_EVENT(CONTEXT_ID IN NUMBER DEFAULT NULL);
220
221 /*
222 ** Tests whether logging is enabled for this level and module, to
223 ** avoid the performance penalty of building long debug message
224 ** strings unnecessarily.
225 */
226 FUNCTION TEST(LOG_LEVEL IN NUMBER,
227 MODULE IN VARCHAR2) RETURN BOOLEAN;
228
229
230 /* This global allows callers to avoid a function call if a log message */
231 /* is not for the current level. It is automatically populated by */
232 /* the FND_LOG_REPOSITORY package.
233 /* Here is an example of how to achieve maximum performance with */
234 /* this, assuming that you want to log a message at EXCEPTION level */
235 /* */
236 /* if((FND_LOG.LEVEL_EXCEPTION >= FND_LOG.G_CURRENT_RUNTIME_LEVEL)) then*/
237 /* if(FND_LOG.TEST(FND_LOG.LEVEL_EXCEPTION */
238 /* 'fnd.form.ABCDEFGH.PACKAGEA.FUNCTIONB.firstlabel')) then*/
239 /* dbg_msg := create_lengthy_debug_message(...);*/
240 /* FND_LOG.STRING(FND_LOG.LEVEL_EXCEPTION, */
241 /* 'fnd.form.ABCDEFGH.PACKAGEA.FUNCTIONB.firstlabel', dbg_msg);*/
242 /* end if; */
243 /* end if;*/
244 G_CURRENT_RUNTIME_LEVEL NUMBER := 6;
245
246 /*
247 ** FND_LOG.GET_TEXT
248 **
249 ** Description:
250 ** Retrieves the fully translated message text, given a log sequence ID
251 **
252 ** Arguments:
253 ** log_sequence_id - FND_LOG message identifier.
254 ** lang - Language code for translation (optional).
255 **
256 ** Returns:
257 ** If an encoded message, the full translated text of the message.
258 ** If message not encoded, the text of the message as logged.
259 ** Returns NULL if the message cannot be found.
260 */
261 FUNCTION GET_TEXT(LOG_SEQUENCE_ID IN NUMBER,
262 LANG IN VARCHAR2 DEFAULT NULL
263 ) RETURN VARCHAR2;
264
265 /**
266 * Procedure to enable PL/SQL Buffered Logging (for Batch Mode).
267 * Caller is responsible for calling RESET_BUFFERED_MODE to flush
271 * Internally reads AFLOG_BUFFER_MODE Profile and if !=0
268 * messages at end. Only messages with log_level < 4 are bufferable.
269 * All error messages (log_level >= 4) are logged immediately.
270 *
272 * buffers messages in PL/SQL Collection for Bulk-Inserting.
273 */
274 PROCEDURE SET_BUFFERED_MODE;
275
276 /**
277 * Flushes any buffered messages, and switches back to the
278 * default synchronous (non-buffered) logging.
279 */
280 PROCEDURE RESET_BUFFERED_MODE;
281
282 /**
283 * API for raising a proxy alert on behalf of the given
284 * concurrent request. The transaction context for the alert is set to
285 * that of the given request ID. The current transaction context is also
286 * captured as a parent context.
287 *
288 * This API does the following:
289 * 1) Sets a child context for the given request ID
290 * 2) Raises the proxy alert by calling fnd_log.message in the normal
294 PROCEDURE PROXY_ALERT_FOR_CONC_REQ(
291 * fashion
292 * 3) Clears the child context.
293 */
295 MODULE IN VARCHAR2,
296 POP_MESSAGE IN BOOLEAN DEFAULT NULL,
297 REQUEST_ID IN NUMBER);
298
299 end FND_LOG;