Process Log Details
Introduction
This document details the process for writing to the process log within Outperform as well as the details of the underlying tables. The screenprint that follows shows the process log within Outperform:
Process required for a new log entry:
Declare variables to store the audit processID and log level. Audit ProcessID will be populated when the user starts the logged event and used for all sub events logged as part of this processID. Log levels give the ability to provide more or less information to the log as the user sees fit. The levels are: -1=none; 0=error; 1=warning; 2=info; 3=debug. Most commonly used is "2=info."
declare @audit_processid int
declare @log_level int = 2
Create a #log table to contain all details to be logged:
create table #log(n int identity, d datetime default getdate(),l int,r int,e varchar(256), i varchar(256),m varchar(256))
n contains an identity field as a unique identifier for all records, system provided;
d contains the system date of the logged entry, system provided;
l contains the logging level (0=error;1=warning;2=info;3=debug);
r contains the row number (if applicable) of the entry being made;
e contains the entity name for the logging entry;
i contains the number of records related to the logging entry;
m contains the message for the logging entry;
Call procedure to start the logging, establish a name for the logged event, and assign a processID. Using the sp_start_import_log, allows the system to recognize this process type as “Integration” and the “Process” as the “Export,” provided as below:
exec sp_start_import_log 'Export', @audit_processid out, @log_level
Insert logging information (could be conditional if the user needs different levels of logging). It is possible to make multiple entries for the same processID to capture different information as the user sees fit. This is accomplished with multiple inserts into the #log table.
if @log_level >= 2 --or some other condition is met...
insert #log(l,r,e,i,m)
select 2,row_number() over (order by error_msg),'cutsheet',1,error_msg
from export where error_msg !=''
Call procedure to end the logging event for the processID established
exec sp_finish_import_log @audit_processid
Sample procedure to handle logging
declare @log_level int = 2 -- -1=none, 0=error, 1=warning, 2=info, 3=debug
declare @audit_processid int
--check for existence of #log, drop and recreate if present
if (select object_id(N'tempdb..#log',N'U')) is not null
drop table #log
create table #log(n int identity, d datetime default getdate(),l int,r int,e varchar(256), i varchar(256),m varchar(256))
exec sp_start_import_log 'Export', @audit_processid out, @log_level
if @log_level >= 2 --or some other condition is met...
insert #log(l,r,e,i,m)
select 2,row_number() over (order by error_msg),'cutsheet',1,error_msg
from export where error_msg !=''
insert into #log(l,r,e,i,m)
select 2,1,'sample',1,'Just a demonstration'
insert into #log(l,r,e,i,m)
select 1,1,'alert!',1,'sample of a warning!'
exec sp_finish_import_log @audit_processid
Tables in use
This section details the tables used in logging. Note that there shouldn’t be a need to write directly to these tables as the procedure calls in the code sample to handle this work.
cdm_audit_log: contains the details of the process log
cdm_audit_process: contains the details of the process- when it started, when it ended, name, etc.
cdm_audit_process_types is an Outperform managed table and should not be modified.
cdm_audit_error, cdm_audit_info, cdm_audit_debug have been deprecated in recent releases and are no longer in use.
Comments
0 comments
Article is closed for comments.