DBA Data[Home] [Help]

PACKAGE BODY: APPS.FLM_EKANBAN_LOGGER

Source


1 package body flm_ekanban_logger as
2  /* $Header: flmflogb.pls 120.1.12020000.2 2012/08/15 01:10:27 ankohli ship $ */
3 
4   --package variables
5   g_indentLevel NUMBER := 0;
6   g_sessionID NUMBER := -1;
7   type char_tbl_t is table of varchar2(2000) index by binary_integer;
8   g_moduleTbl char_tbl_t;
9   --package constants
10   g_maxMsgLen NUMBER := 255;
11   g_maxIndentLevel NUMBER := 10;
12   g_indentOffset NUMBER := 2;
13   g_anonModule VARCHAR2(30) := 'FLM.EKANBAN.';
14 
15   procedure init(x_returnStatus     out NOCOPY VARCHAR2);
16 
17   procedure write(p_logLevel IN NUMBER,
18                   p_msg IN VARCHAR2,
19                   x_returnStatus out NOCOPY VARCHAR2);
20 
21   procedure log(p_logLevel IN NUMBER,
22                 p_msg           IN VARCHAR2,
23                 x_returnStatus out NOCOPY VARCHAR2) is
24 	l_returnStatus VARCHAR2(1);
25   begin
26     write(p_logLevel => p_logLevel,
27           p_msg => p_msg,
28           x_returnStatus => l_returnStatus);
29   end log;
30 
31   procedure entryPoint(p_logLevel IN NUMBER,
32                        p_procName      IN VARCHAR2,
33                        p_params        IN param_tbl_t,
34                        x_returnStatus out NOCOPY VARCHAR2) is
35   begin
36     x_returnStatus := fnd_api.g_ret_sts_success;
37     g_indentLevel := least(g_indentLevel + 1, g_maxIndentLevel);
38 
39     g_moduleTbl(nvl(g_moduleTbl.last, 0) + 1) := 'FLM.EKANBAN.PLSQL.' || p_procName;
40 
41     write(p_msg          => '[begin ' || p_procName || ']',
42           p_logLevel     => p_logLevel,
43           x_returnStatus => x_returnStatus);
44     if(x_returnStatus <> fnd_api.g_ret_sts_success) then
45        raise fnd_api.g_exc_unexpected_error;
46     end if;
47     for i in 1..p_params.count loop
48       write(p_msg          => '  ' || p_params(i).paramName || ': ' || p_params(i).paramValue,
49             p_logLevel     => p_logLevel,
50             x_returnStatus => x_returnStatus);
51       if(x_returnStatus <> fnd_api.g_ret_sts_success) then
52          raise fnd_api.g_exc_unexpected_error;
53       end if;
54     end loop;
55 
56   exception
57     when others then
58       null;--write() will set all return values properly
59   end entryPoint;
60 
61  procedure entryPointNoParams(p_logLevel  IN NUMBER,
62 			      p_procName  IN VARCHAR2,
63                               x_returnStatus out NOCOPY VARCHAR2) is
64   l_returnStatus varchar2(1);
65   begin
66     l_returnStatus := fnd_api.g_ret_sts_success;
67     g_indentLevel := least(g_indentLevel + 1, g_maxIndentLevel);
68     g_moduleTbl(nvl(g_moduleTbl.last, 0) + 1) := 'FLM.EKANBAN.JAVA.' || p_procName;
69 
70     write(p_msg          => '[begin ' || p_procName || ']',
71           p_logLevel     => p_logLevel,
72           x_returnStatus => l_returnStatus);
73     if(l_returnStatus <> fnd_api.g_ret_sts_success) then
74        raise fnd_api.g_exc_unexpected_error;
75     end if;
76   exception
77     when others then
78       null;--write() will set all return values properly
79   end entryPointNoParams;
80 
81   procedure exitPoint(p_logLevel IN NUMBER,
82                       p_procName          IN VARCHAR2,
83                       p_procReturnStatus  IN VARCHAR2,
84                       p_msg               IN VARCHAR2,
85                       x_returnStatus     out NOCOPY VARCHAR2) is
86   begin
87     x_returnStatus := fnd_api.g_ret_sts_success;
88 
89     write(p_msg          => '[end ' || p_procName || ']',
90           p_logLevel     => p_logLevel,
91           x_returnStatus => x_returnStatus);
92     if(x_returnStatus <> fnd_api.g_ret_sts_success) then
93       raise fnd_api.g_exc_unexpected_error;
94     end if;
95 
96     write(p_msg          => '  return status: ' || p_procReturnStatus,
97           p_logLevel     => p_logLevel,
98           x_returnStatus => x_returnStatus);
99     if(x_returnStatus <> fnd_api.g_ret_sts_success) then
100       raise fnd_api.g_exc_unexpected_error;
101     end if;
102 
103     write(p_msg          => '  info: ' || p_msg,
104           p_logLevel     => p_logLevel,
105           x_returnStatus => x_returnStatus);
106     if(x_returnStatus <> fnd_api.g_ret_sts_success) then
107       raise fnd_api.g_exc_unexpected_error;
108     end if;
109 
110     --this if should always be true
111     if(g_moduleTbl.last is not null) then
112       g_moduleTbl.delete(g_moduleTbl.last);
113     end if;
114     g_indentLevel := greatest(g_indentLevel - 1, 0);
115   exception
116     when others then
117       --write() will set all return parameters correctly
118       g_indentLevel := greatest(g_indentLevel - 1, 0);
119   end exitPoint;
120 
121   procedure cleanUp(x_returnStatus     out NOCOPY VARCHAR2) is
122   begin
123     write(p_msg          => 'Session ' || g_sessionID || ': ended on ' || to_char(sysdate, 'MM/DD/YYYY HH24:MI:SS'),
124           p_logLevel     => full_logging,
125           x_returnStatus => x_returnStatus);
126     g_sessionID := -1;
127     g_indentLevel := 0;
128     g_moduleTbl.delete;
129 
130     x_returnStatus := fnd_api.g_ret_sts_success;
131   exception
132     when others then
133       x_returnStatus := fnd_api.g_ret_sts_unexp_error;
134       fnd_msg_pub.add_exc_msg(p_pkg_name       => 'flm_ekanban_logger',
135                               p_procedure_name => 'cleanUp',
136                               p_error_text     => SQLERRM);
137   end cleanUp;
138 
139   procedure write(p_logLevel     IN NUMBER,
140                   p_msg          IN VARCHAR2,
141                   x_returnStatus out NOCOPY VARCHAR2) is
142     l_msg VARCHAR2(2000);
143     l_module VARCHAR2(2000);
144     l_retStatus varchar2(1);
145   begin
146     x_returnStatus := fnd_api.g_ret_sts_unexp_error;
147     if(g_sessionID < 0) then
148       init(x_returnStatus => x_returnStatus);
149       if(x_returnStatus <> fnd_api.g_ret_sts_success) then
150         raise fnd_api.g_exc_unexpected_error;
151       end if;
152     end if;
153     l_msg := 'Session ' || g_sessionID || ': ';
154     l_msg := lpad(l_msg, g_indentLevel * g_indentOffset + length(l_msg), ' ');
155     l_msg := l_msg || substr(p_msg, 0, g_maxMsgLen - length(l_msg));
156     x_returnStatus := fnd_api.g_ret_sts_unexp_error;
157     if(g_moduleTbl.last is null) then
158       g_moduleTbl(1) := g_anonModule;
159     end if;
160 
161     -- to work around GSCC, the call to fnd_log.string needs to pass
162     -- accordingly...
163     if ( p_logLevel = FND_LOG.LEVEL_STATEMENT AND
164          FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_STATEMENT ) then
165        fnd_log.string(log_level => FND_LOG.LEVEL_STATEMENT,
166                       module => g_moduleTbl(g_moduleTbl.last),
167                       message => l_msg);
168     elsif ( p_logLevel = FND_LOG.LEVEL_PROCEDURE AND
169             FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_PROCEDURE ) then
170        fnd_log.string(log_level => FND_LOG.LEVEL_PROCEDURE,
171                       module => g_moduleTbl(g_moduleTbl.last),
172                       message => l_msg);
173     elsif ( p_logLevel = FND_LOG.LEVEL_EVENT AND
174             FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_EVENT ) then
175        fnd_log.string(log_level => FND_LOG.LEVEL_EVENT,
176                       module => g_moduleTbl(g_moduleTbl.last),
177                       message => l_msg);
178     elsif ( p_logLevel = FND_LOG.LEVEL_EXCEPTION AND
179             FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_EXCEPTION ) then
180        fnd_log.string(log_level => FND_LOG.LEVEL_EXCEPTION,
181                       module => g_moduleTbl(g_moduleTbl.last),
182                       message => l_msg);
183     elsif ( p_logLevel = FND_LOG.LEVEL_ERROR AND
184             FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_ERROR ) then
185        fnd_log.string(log_level => FND_LOG.LEVEL_ERROR,
186                       module => g_moduleTbl(g_moduleTbl.last),
187                       message => l_msg);
188     elsif ( p_logLevel = FND_LOG.LEVEL_UNEXPECTED AND
189             FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_UNEXPECTED ) then
190         fnd_log.string(log_level => FND_LOG.LEVEL_UNEXPECTED,
191                       module => g_moduleTbl(g_moduleTbl.last),
192                       message => l_msg);
193     end if;
194 
195     x_returnStatus := fnd_api.g_ret_sts_success;
196   exception
197     when others then
198       x_returnStatus := fnd_api.g_ret_sts_unexp_error;
199       fnd_msg_pub.add_exc_msg(p_pkg_name       => 'flm_ekanban_logger',
200                               p_procedure_name => 'write',
201                               p_error_text     => SQLERRM);
202   end write;
203 
204   procedure init(x_returnStatus     out NOCOPY VARCHAR2) is
205   begin
206     x_returnStatus := fnd_api.g_ret_sts_success;
207     g_indentLevel := 0;
208 
209     if(g_sessionID < 0) then
210       select wip_logging_session_s.nextval
211         into g_sessionID
212         from dual;
213     end if;
214     write(p_msg => 'Session ' || g_sessionID || ': started on ' || to_char(sysdate, 'MM/DD/YYYY HH24:MI:SS'),
215           p_logLevel => trace_logging,
216           x_returnStatus => x_returnStatus);
217   end init;
218 end flm_ekanban_logger;