1 PACKAGE DOM_LOG as
2 /* $Header: DOMULOGS.pls 120.0 2006/07/14 22:16:18 mkimizuk noship $*/
3
4 /* --------------------------------------------------------------------
5 -- DOM_LOG package is wrapper of FND_LOG and PL/SQL Utiliteis to
6 -- for DOM Loggin Framework on top of Oracle Applications Logging Framework
7 --
8 -- The Oracle Applications Logging Framework (aka FND Logging Framework)
9 -- allows developers to log debug, error and alert messages to a central repository
10 -- which is shared by both database and middle-tier servers. PL/SQL, Java, and C APIs are provided.
11 -- There are numerous mechanisms available for controlling which messages are logged.
12 -- Documentation for this package is at
13 -- http://www-apps.us.oracle.com:1100/logging/
14 --
15 --
16 --
17 -- How to Log from PL/SQL in OA Logging Fwk
18 --
19 -- PL/SQL APIs are a part of the FND_LOG Package.
20 -- These APIs assume that appropriate application user session initialization APIs
21 -- (for example, FND_GLOBAL.INITIALIZE(..)) have already been invoked for setting up
22 -- the user session properties on the database Session. These application user session
23 -- properties (UserId, RespId, AppId, SessionId) are internally needed for the Log APIs.
24 -- Typically, all Oracle Application Frameworks (CP, OAF, JTT, Forms, etc.) take care of
25 -- invoking these session initialization APIs for you.
26 -- Plain-text messages should be logged using FND_LOG.STRING(..),
27 -- and translatable Message Dictionary Messages should be logged using FND_LOG.MESSAGE(..). FND_LOG.MESSAGE(..) logs
28 -- the Message in encoded (not translated) format, and allows the Log Viewer UI to handle the translation of the Message
29 -- based on the language preferences of the Sysadmin viewing the Messages.
30 -- For FND_LOG API details please refer to: $fnd/patch/115/sql/AFUTLOGB.pls
31 --
32 -- In DOM PL/SQL API, utilize DOM_LOG Package which is the wrapper util of FND_LOG
33 --
34 -- DOM Log Level is defined in global var DOM_LOG_LEVEL CONSTANT NUMBER default: FND_LOG.LEVEL_PROCEDURE
35 --
36 --
37 -- Example
38 -- Assuming AOL Session Initialization has occurred and logging is enabled, the following calls would log a message:
39 -- begin
40 --
41 -- -- Here is where you would call a routine that logs messages
42 -- -- Important Performance check, see if logging is enabled
43 -- IF ( DOM_LOG.CHECK_LOG_LEVEL) THEN
44 -- DOM_LOG.LOG_STR(PKG_NAME -- Normaly you should define this global var
45 -- , 'Your_Procedure' -- API Name. Normally you should define l_api_name at the beginning and pass it
46 -- , 'Your_Label' -- Optional. Appended after API Name. e.g. begin, end
47 -- , 'Hello, world!' );
48 -- END IF ;
49 --
50 -- Log Module will be 'dom.plsql.PKG_NAME.Your_Procedure.Your_Label'
51 --
52 -- -- Note: For Forms Client PL/SQL, the APIs are the same, except that for checking
53 -- if logging is enabled, you should call DOM_LOG.TEST(..)
54 -- -- Note: If you change G_DEV_DEBUG in DOM_LOG PKG Body to '1' and compile it in devlopment env
55 -- the message is written in conc log file under 'utl_file_dir' specified in DB Param
56 --
57 ------------------------------------------------------------------------------------------
58 -- How to Turn On Logging
59 ------------------------------------------------------------------------------------------
60 -- In normal circumstances, the PL/SQL layer logging is automatically initialized by
61 -- the enclosing Apps component's AOL Session Management layer, i.e. Forms, Concurrent
62 -- Manager, Java Framework- SSWA, JTF, OA, etc. In some rare circumstances,
63 -- for example, if you are debugging an issue, you may need to manually initialize
64 -- the PL/SQL layer logging for the current session. From the SQL*Prompt, you could do this by calling:
65 --
66 -- FND_GLOBAL.APPS_INITIALIZE(fnd_user_id, fnd_resp_id, fnd_appl_id);
67 -- fnd_profile.put('AFLOG_ENABLED', 'Y');
68 -- fnd_profile.put('AFLOG_MODULE', 'dom%');
69 -- fnd_profile.put('AFLOG_LEVEL', '2');
70 -- fnd_profile.put('AFLOG_FILENAME', '');
71 -- fnd_log_repository.init;
72 --
73 -- Do not ship any code with these calls! Shipping code that internally hard codes
74 -- Log Properties is a severe P1 bug. Logging should always be externally configurable
75 -- using the Log Properties, and internally hard coding log properties would prevent this.
76 --
77 -------------------------------------------------------------------------------------------
78 -- Viewing Log Messages
79 -------------------------------------------------------------------------------------------
80 --
81 -- OA Framework Pages
82 -- When working in OA Framework pages, follow this procedure to view your log messages.
83 -- 1.) Applications pages based on the OA Framework have a global button labeled Diagnostics.
84 -- Click this button to open a window where you can choose between Show Log and Set Trace Level.
85 -- 2.) Choose Show Log to open the Logs page within Oracle Applications Manager.
86 -- The Logs page is part of the System Alerts and Metrics feature.
87 -- Note: For the Diagnostics global button to be visible, the profile option FND_DIAGNOSTICS must be set to Yes.
88 --
89 -- Oracle Applications Manager (OAM) or System Administrator -> OAM: Logs
90 -- OAM is part of 11.5.9, and is typically accessible on any 11.5.9 instance from a URL like:
91 -- http://host:port/servlets/weboam/oam/oamLogin
92 -- From the drop-down-list, navigate to "System Alerts and Metrics" -> Logs
93 -- Fyi, "Advanced Search" allows you to query by CP-Name.
94 -- (Starting 11.5.10, you will be able to query by CP Request-Id too).
95 --
96 --------------------------------------------------------------------*/
97
98
99 /*--------------------------------------------------------------------
100 -- Constant Variables
101 --------------------------------------------------------------------*/
102
103 ---------------------------------------
104 -- Package Name
105 ---------------------------------------
106 G_PKG_NAME CONSTANT VARCHAR2(30):='DOM_LOG';
107
108 ---------------------------------------
109 -- LOG Level
110 ---------------------------------------
111 LEVEL_UNEXPECTED CONSTANT NUMBER := FND_LOG.LEVEL_UNEXPECTED ; -- 6
112 LEVEL_ERROR CONSTANT NUMBER := FND_LOG.LEVEL_ERROR; -- 5
113 LEVEL_EXCEPTION CONSTANT NUMBER := FND_LOG.LEVEL_EXCEPTION; -- 4
114 LEVEL_EVENT CONSTANT NUMBER := FND_LOG.LEVEL_EVENT; -- 3
115 LEVEL_PROCEDURE CONSTANT NUMBER := FND_LOG.LEVEL_PROCEDURE; -- 2
116 LEVEL_STATEMENT CONSTANT NUMBER := FND_LOG.LEVEL_PROCEDURE; -- 1
117
118 ---------------------------------------
119 -- DOM LOG Level
120 ---------------------------------------
121 -- We enable Dom PL/SQL Log at FND_LOG.LEVEL_PROCEDURE Level
122 DOM_LOG_LEVEL CONSTANT NUMBER := FND_LOG.LEVEL_PROCEDURE ;
123
124 ---------------------------------------
125 -- DOM LOG Module Prefix
126 ---------------------------------------
127 -- We enable Dom PL/SQL Log at FND_LOG.LEVEL_PROCEDURE Level
128 DOM_LOG_PREFIX CONSTANT VARCHAR2(10) := 'dom.plsql.' ;
129
130
131 --
132 -- Writes the message to the log file for the specified
133 -- level and module
134 -- if logging is enabled for this level and module
135 --
136 PROCEDURE LOG_STR(PKG_NAME IN VARCHAR2,
137 API_NAME IN VARCHAR2,
138 LABEL IN VARCHAR2 := NULL,
139 MESSAGE IN VARCHAR2);
140
141 /*-------------------------------------
142 -- Will implement if needed
143 PROCEDURE STRING(PKG_NAME IN VARCHAR2,
144 API_NAME IN VARCHAR2,
145 MESSAGE IN VARCHAR2);
146
147
148 PROCEDURE STRING(LOG_LEVEL IN NUMBER,
149 MODULE IN VARCHAR2,
150 MESSAGE IN VARCHAR2);
151 -------------------------------------*/
152
153 /*-----------------------------------------------------------
154 -- Will implement if needed
155 --
156 -- Writes a message to the log file if this level and module
157 -- are enabled.
158 -- The message gets set previously with FND_MESSAGE.SET_NAME,
159 -- SET_TOKEN, etc.
160 -- The message is popped off the message dictionary stack,
161 -- if POP_MESSAGE is TRUE.
162 -- Pass FALSE for POP_MESSAGE if the message will also be
163 -- displayed to the user later.
164 -- Example usage:
165 -- FND_MESSAGE.SET_NAME(...); -- Set message
166 -- FND_MESSAGE.SET_TOKEN(...); -- Set token in message
167 -- FND_LOG.MESSAGE(..., FALSE); -- Log message
168 -- FND_MESSAGE.RAISE_ERROR; -- Display message
169 PROCEDURE MESSAGE(MODULE IN VARCHAR2,
170 POP_MESSAGE IN BOOLEAN DEFAULT NULL);
171
172
173 PROCEDURE MESSAGE(LOG_LEVEL IN NUMBER,
174 MODULE IN VARCHAR2,
175 POP_MESSAGE IN BOOLEAN DEFAULT NULL);
176 -----------------------------------------------------------*/
177
178 --
179 -- Tests whether logging is enabled for this level and module,
180 -- to avoid the performance penalty of building long debug
181 -- message strings unnecessarily.
182 --
183 FUNCTION TEST(PKG_NAME IN VARCHAR2,
184 API_NAME IN VARCHAR2)
185 RETURN BOOLEAN;
186
187
188 /*-----------------------------------------------------------
189 -- Will implement if needed
190 FUNCTION TEST(LOG_LEVEL IN NUMBER
191 , MODULE IN VARCHAR2)
192 RETURN BOOLEAN;
193 -----------------------------------------------------------*/
194
195 --
196 -- Tests whether DOM logging is enabled for this level
197 --
198 FUNCTION CHECK_LOG_LEVEL
199 RETURN BOOLEAN;
200
201
202 END DOM_LOG ;