Add support for creating Dependent directories.
This commit is contained in:
@ -16,12 +16,17 @@ Function Logging_Services(@Service, @Params)
|
|||||||
Param1-10 [in/out] -- Additional request parameter holders
|
Param1-10 [in/out] -- Additional request parameter holders
|
||||||
Response [out] -- Response to be sent back to the Controller (MCP) or requesting procedure
|
Response [out] -- Response to be sent back to the Controller (MCP) or requesting procedure
|
||||||
|
|
||||||
Metadata :
|
|
||||||
|
|
||||||
History : (Date, Initials, Notes)
|
History : (Date, Initials, Notes)
|
||||||
08/30/17 dmb Original programmer.
|
08/30/17 dmb Original programmer.
|
||||||
02/17/18 dmb Use the new named cache feature of Memory_Services so logging data is protected when other
|
02/17/18 dmb [SRPFW-225] Use the new named cache feature of Memory_Services so logging data is
|
||||||
processes release a cache table.
|
protected when other processes release a cache table.
|
||||||
|
05/07/18 sgb [SRPFW-225] Fix bug in NewLog service by using the LogFullPath variable instead of the
|
||||||
|
04/24/20 gac Modified the AppendLog service to refresh the FielSize if the ColumnHeaders are added.
|
||||||
|
05/09/20 dmb [SRPFW-313] Merged with other versions.
|
||||||
|
08/28/24 djm Add CreateDirectory argument to NewLog service. If set to true, non-existent directories
|
||||||
|
will be created if necessary to save the log.
|
||||||
|
|
||||||
***********************************************************************************************************************/
|
***********************************************************************************************************************/
|
||||||
|
|
||||||
@ -37,13 +42,14 @@ Equ LF$ to \0A\
|
|||||||
Equ TAB$ to \09\
|
Equ TAB$ to \09\
|
||||||
Equ COMMA$ to ','
|
Equ COMMA$ to ','
|
||||||
|
|
||||||
Common /LogginServices/ Unused1@, Unused2@, Unused3@, Unused4@, Unused5@, Unused6@, Unused7@, Unused8@
|
Common /LoggingServices/ Unused1@, Unused2@, Unused3@, Unused4@, Unused5@, Unused6@, Unused7@, Unused8@
|
||||||
|
|
||||||
Declare function Logging_Services, Memory_Services, SRP_Hash, SRP_Path, SRP_Send_Mail, Environment_Services
|
Declare function Logging_Services, Memory_Services, SRP_Hash, SRP_Path, SRP_Send_Mail, Environment_Services
|
||||||
Declare subroutine Logging_Services, Memory_Services, SetInitDirOptions
|
Declare function RTI_OS_Directory
|
||||||
|
Declare subroutine Logging_Services, Memory_Services, SetInitDirOptions
|
||||||
|
|
||||||
GoToService else
|
GoToService else
|
||||||
Error_Services('Add', Service : ' is not a valid service request within the Logging services module.')
|
Error_Services('Set', Service : ' is not a valid service request within the ' : ServiceModule : ' services module.')
|
||||||
end
|
end
|
||||||
|
|
||||||
Return Response OR ''
|
Return Response OR ''
|
||||||
@ -74,51 +80,65 @@ Options BOOLEAN = True$, False$
|
|||||||
// QuoteValues - Boolean flag to indicate if column values should be quoted. Default is false. - [Optional]
|
// QuoteValues - Boolean flag to indicate if column values should be quoted. Default is false. - [Optional]
|
||||||
// ClearLog - Boolean flag to indicate if any existing log file should be cleared. Default is false.
|
// ClearLog - Boolean flag to indicate if any existing log file should be cleared. Default is false.
|
||||||
// - [Optional]
|
// - [Optional]
|
||||||
|
// CreateDirectory - Boolean flag to indicate if dependent directories should be created. Default is false.
|
||||||
|
// - [Optional]
|
||||||
//
|
//
|
||||||
// Returns an object handle to a log file.
|
// Returns an object handle to a log file.
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------------------------
|
||||||
Service NewLog(LogPath, LogFileName, RowDelimiter, ColumnDelimiter, ColumnHeaders, ColumnWidths, QuoteValues=BOOLEAN, ClearLog=BOOLEAN)
|
Service NewLog(LogPath, LogFileName, RowDelimiter, ColumnDelimiter, ColumnHeaders, ColumnWidths, QuoteValues=BOOLEAN, ClearLog=BOOLEAN, CreateDirectory=BOOLEAN)
|
||||||
|
|
||||||
objLog = ''
|
DirectoryCreated = ''
|
||||||
|
objLog = ''
|
||||||
If (LogPath NE '') AND (LogFileName NE '') then
|
If CreateDirectory EQ '' then CreateDirectory = TRUE$
|
||||||
If SRP_Path('Exists', LogPath) then
|
|
||||||
LogFullPath = SRP_Path('Combine', LogPath, LogFileName)
|
If (LogPath NE '') AND (LogFileName NE '') then
|
||||||
If LogFullPath[1, 1] EQ '\' AND LogFullPath[2, 1] NE '\' then LogFullPath = '\' : LogFullPath
|
If (SRP_Path('Exists', LogPath) EQ False$) AND (CreateDirectory EQ TRUE$) then
|
||||||
objLog = SRP_Hash(LogFullPath, 'SHA-1', 'BASE32')
|
GoSub CreateDependentDirectories
|
||||||
Memory_Services('SetValue', objLog : '*LogPath', LogPath, ServiceModule)
|
end
|
||||||
Memory_Services('SetValue', objLog : '*LogFileName', LogFileName, ServiceModule)
|
If SRP_Path('Exists', LogPath) then
|
||||||
Memory_Services('SetValue', objLog : '*LogFullPath', LogFullPath, ServiceModule)
|
LogFullPath = SRP_Path('Combine', LogPath, LogFileName)
|
||||||
If Dir(LogFullPath) NE '' then
|
If LogFullPath[1, 1] EQ '\' AND LogFullPath[2, 1] NE '\' then LogFullPath = '\' : LogFullPath
|
||||||
If ClearLog then
|
objLog = SRP_Hash(LogFullPath, 'SHA-1', 'BASE32')
|
||||||
Logging_Services('CreateLogFile', objLog)
|
Memory_Services('SetValue', objLog : '*LogPath', LogPath, ServiceModule)
|
||||||
end
|
Memory_Services('SetValue', objLog : '*LogFileName', LogFileName, ServiceModule)
|
||||||
end else
|
Memory_Services('SetValue', objLog : '*LogFullPath', LogFullPath, ServiceModule)
|
||||||
Logging_Services('CreateLogFile', objLog)
|
If Dir(LogFullPath) NE '' then
|
||||||
end
|
If ClearLog then
|
||||||
If Error_Services('NoError') then
|
Logging_Services('CreateLogFile', objLog)
|
||||||
If RowDelimiter EQ '' then RowDelimiter = CRLF$
|
end
|
||||||
Memory_Services('SetValue', objLog : '*RowDelimiter', RowDelimiter, ServiceModule)
|
end else
|
||||||
If (ColumnDelimiter EQ '') AND (ColumnWidths EQ '') then ColumnDelimiter = COMMA$
|
Logging_Services('CreateLogFile', objLog)
|
||||||
Memory_Services('SetValue', objLog : '*ColumnDelimiter', ColumnDelimiter, ServiceModule)
|
end
|
||||||
Memory_Services('SetValue', objLog : '*ColumnHeaders', ColumnHeaders, ServiceModule)
|
If Error_Services('NoError') then
|
||||||
Memory_Services('SetValue', objLog : '*ColumnWidths', ColumnWidths, ServiceModule)
|
If RowDelimiter EQ '' then RowDelimiter = CRLF$
|
||||||
If QuoteValues NE True$ then QuoteValues = False$
|
Memory_Services('SetValue', objLog : '*RowDelimiter', RowDelimiter, ServiceModule)
|
||||||
Memory_Services('SetValue', objLog : '*QuoteValues', QuoteValues, ServiceModule)
|
If (ColumnDelimiter EQ '') AND (ColumnWidths EQ '') then ColumnDelimiter = COMMA$
|
||||||
If Dir(LogFullPath)<1> EQ 0 AND ColumnHeaders NE '' then
|
Memory_Services('SetValue', objLog : '*ColumnDelimiter', ColumnDelimiter, ServiceModule)
|
||||||
// Add the column headers since this is a new log file.
|
Memory_Services('SetValue', objLog : '*ColumnHeaders', ColumnHeaders, ServiceModule)
|
||||||
Logging_Services('AppendLog', objLog, ColumnHeaders, '', @FM, True$)
|
Memory_Services('SetValue', objLog : '*ColumnWidths', ColumnWidths, ServiceModule)
|
||||||
end
|
If QuoteValues NE True$ then QuoteValues = False$
|
||||||
end
|
Memory_Services('SetValue', objLog : '*QuoteValues', QuoteValues, ServiceModule)
|
||||||
end else
|
If Dir(LogFullPath)<1> EQ 0 AND ColumnHeaders NE '' then
|
||||||
Error_Services('Add', LogPath : ' does not exist.')
|
// Add the column headers since this is a new log file.
|
||||||
end
|
Logging_Services('AppendLog', objLog, ColumnHeaders, '', @FM, True$)
|
||||||
end else
|
end
|
||||||
Error_Services('Add', 'LogPath or LogFileName argument was missing from the ' : Service : ' service.')
|
end
|
||||||
end
|
|
||||||
|
end else
|
||||||
Response = objLog
|
If CreateDirectory EQ False$ then
|
||||||
|
Error_Services('Add', LogPath : ' does not exist.')
|
||||||
|
end else
|
||||||
|
If (CreateDirectory EQ True$) and (DirectoryCreated EQ False$) then
|
||||||
|
Error_Services('Add', LogPath : ' could not be created.')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end else
|
||||||
|
Error_Services('Add', 'LogPath or LogFileName argument was missing from the ' : Service : ' service.')
|
||||||
|
end
|
||||||
|
|
||||||
|
Response = objLog
|
||||||
|
|
||||||
end service
|
end service
|
||||||
|
|
||||||
|
|
||||||
@ -138,70 +158,73 @@ end service
|
|||||||
// log file. Default is false. - [Optional]
|
// log file. Default is false. - [Optional]
|
||||||
// EmailAddresses - Comma delimited list of email addresses that should be notified when this log is appended.
|
// EmailAddresses - Comma delimited list of email addresses that should be notified when this log is appended.
|
||||||
// - [Optional]
|
// - [Optional]
|
||||||
// EmailMessage - Message to be sent to the email addresses.
|
// EmailMessage - Message to be sent to the email addresses.
|
||||||
//
|
//
|
||||||
// Appends data to the log file associated with the indicated log object handle.
|
// Appends data to the log file associated with the indicated log object handle.
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------------------------
|
||||||
Service AppendLog(objLog, LogData, IncomingRowDelimiter, IncomingColumnDelimiter, IgnoreColumnHeaders, EmailAddresses, EmailMessage)
|
Service AppendLog(objLog, LogData, IncomingRowDelimiter, IncomingColumnDelimiter, IgnoreColumnHeaders, EmailAddresses, EmailMessage)
|
||||||
|
|
||||||
If (objLog NE '') AND (LogData NE '') then
|
If (objLog NE '') AND (LogData NE '') then
|
||||||
If IgnoreColumnHeaders NE True$ then IgnoreColumnHeaders = False$
|
If IgnoreColumnHeaders NE True$ then IgnoreColumnHeaders = False$
|
||||||
LogFullPath = Logging_Services('GetLogFullPath', objLog)
|
LogFullPath = Logging_Services('GetLogFullPath', objLog)
|
||||||
ColumnDelimiter = Logging_Services('GetColumnDelimiter', objLog)
|
ColumnDelimiter = Logging_Services('GetColumnDelimiter', objLog)
|
||||||
LenColDel = Len(ColumnDelimiter)
|
LenColDel = Len(ColumnDelimiter)
|
||||||
ColumnHeaders = Logging_Services('GetColumnHeaders', objLog)
|
ColumnHeaders = Logging_Services('GetColumnHeaders', objLog)
|
||||||
ColumnWidths = Logging_Services('GetColumnWidths', objLog)
|
ColumnWidths = Logging_Services('GetColumnWidths', objLog)
|
||||||
QuoteValues = Logging_Services('GetQuoteValues', objLog)
|
QuoteValues = Logging_Services('GetQuoteValues', objLog)
|
||||||
RowDelimiter = Logging_Services('GetRowDelimiter', objLog)
|
RowDelimiter = Logging_Services('GetRowDelimiter', objLog)
|
||||||
If IncomingRowDelimiter EQ '' then IncomingRowDelimiter = RowDelimiter
|
If IncomingRowDelimiter EQ '' then IncomingRowDelimiter = RowDelimiter
|
||||||
If (IncomingColumnDelimiter EQ '') AND (ColumnWidths EQ '') then IncomingColumnDelimiter = ColumnDelimiter
|
If (IncomingColumnDelimiter EQ '') AND (ColumnWidths EQ '') then IncomingColumnDelimiter = ColumnDelimiter
|
||||||
LenRowDel = Len(RowDelimiter)
|
LenRowDel = Len(RowDelimiter)
|
||||||
FileInfo = Dir(LogFullPath)
|
FileInfo = Dir(LogFullPath)
|
||||||
FileSize = FileInfo<1>
|
FileSize = FileInfo<1>
|
||||||
Status() = 0
|
Status() = 0
|
||||||
OutData = ''
|
OutData = ''
|
||||||
OSOpen LogFullPath to hFile then
|
OSOpen LogFullPath to hFile then
|
||||||
If (FileSize EQ 0) AND (ColumnHeaders NE '') AND (Not(IgnoreColumnHeaders)) then
|
If (FileSize EQ 0) AND (ColumnHeaders NE '') AND (Not(IgnoreColumnHeaders)) then
|
||||||
Logging_Services('AppendLog', objLog, ColumnHeaders, @RM, @FM, True$)
|
Logging_Services('AppendLog', objLog, ColumnHeaders, @RM, @FM, True$)
|
||||||
end
|
// Need to refresh FileSize to prevent the Column Headers being overwritten - gac 04/24/20
|
||||||
For Each RowData in LogData using IncomingRowDelimiter
|
FileInfo = Dir(LogFullPath)
|
||||||
If RowData NE '' then
|
FileSize = FileInfo<1>
|
||||||
For Each ColumnData in RowData using IncomingColumnDelimiter setting cPos
|
end
|
||||||
If ColumnWidths NE '' then
|
For Each RowData in LogData using IncomingRowDelimiter
|
||||||
ColumnWidth = ColumnWidths<cPos>
|
If RowData NE '' then
|
||||||
ColumnData = ColumnData[1, ColumnWidth] : Str(' ', ColumnWidth - Len(ColumnData))
|
For Each ColumnData in RowData using IncomingColumnDelimiter setting cPos
|
||||||
end
|
If ColumnWidths NE '' then
|
||||||
If QuoteValues then
|
ColumnWidth = ColumnWidths<cPos>
|
||||||
Swap '"' with '""' in ColumnData ; // Encode the quotes properly.
|
ColumnData = ColumnData[1, ColumnWidth] : Str(' ', ColumnWidth - Len(ColumnData))
|
||||||
ColumnData = Quote(ColumnData)
|
end
|
||||||
end
|
If QuoteValues then
|
||||||
OutData := ColumnData : ColumnDelimiter
|
Swap '"' with '""' in ColumnData ; // Encode the quotes properly.
|
||||||
Next ColumnData
|
ColumnData = Quote(ColumnData)
|
||||||
OutData[Neg(LenColDel), LenColDel] = '' ; // Strip off the last column delimiter.
|
end
|
||||||
OutData := RowDelimiter ; // Append a row delimiter.
|
OutData := ColumnData : ColumnDelimiter
|
||||||
end
|
Next ColumnData
|
||||||
Next LogRow
|
OutData[Neg(LenColDel), LenColDel] = '' ; // Strip off the last column delimiter.
|
||||||
OutData[Neg(LenRowDel), LenRowDel] = '' ; // Strip off the last row delimiter.
|
OutData := RowDelimiter ; // Append a row delimiter.
|
||||||
If (FileSize NE 0) then OutData = RowDelimiter : OutData ; // Prepend a row delimiter since there is existing data.
|
end
|
||||||
OSBWrite OutData to hFile at FileSize
|
Next RowData
|
||||||
OSError = Status()
|
OutData[Neg(LenRowDel), LenRowDel] = '' ; // Strip off the last row delimiter.
|
||||||
If OSError then
|
If (FileSize NE 0) then OutData = RowDelimiter : OutData ; // Prepend a row delimiter since there is existing data.
|
||||||
Error_Services('Add', 'OSBWrite error code ' : OSError : ' in the ' : Service : ' service.')
|
OSBWrite OutData to hFile at FileSize
|
||||||
end
|
OSError = Status()
|
||||||
OSClose hFile
|
If OSError then
|
||||||
end else
|
Error_Services('Add', 'OSBWrite error code ' : OSError : ' in the ' : Service : ' service.')
|
||||||
OSError = Status()
|
end
|
||||||
Error_Services('Add', 'OSOpen error code ' : OSError : ' in the ' : Service : ' service.')
|
OSClose hFile
|
||||||
end
|
end else
|
||||||
|
OSError = Status()
|
||||||
end else
|
Error_Services('Add', 'OSOpen error code ' : OSError : ' in the ' : Service : ' service.')
|
||||||
Error_Services('Add', 'objLog argument was missing from the ' : Service : ' service.')
|
end
|
||||||
end
|
|
||||||
|
end else
|
||||||
If EmailAddresses NE '' then
|
Error_Services('Add', 'objLog argument was missing from the ' : Service : ' service.')
|
||||||
GoSub EmailMessage
|
end
|
||||||
end
|
|
||||||
|
If EmailAddresses NE '' then
|
||||||
|
GoSub EmailMessage
|
||||||
|
end
|
||||||
|
|
||||||
end service
|
end service
|
||||||
|
|
||||||
|
|
||||||
@ -214,20 +237,20 @@ end service
|
|||||||
// the log file itself.
|
// the log file itself.
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------------------------
|
||||||
Service GetLogPath(objLog)
|
Service GetLogPath(objLog)
|
||||||
|
|
||||||
LogPath = ''
|
LogPath = ''
|
||||||
|
|
||||||
If objLog NE '' then
|
If objLog NE '' then
|
||||||
LogPath = Memory_Services('GetValue', objLog : '*LogPath', '', '', ServiceModule)
|
LogPath = Memory_Services('GetValue', objLog : '*LogPath', '', '', ServiceModule)
|
||||||
If LogPath EQ '' then
|
If LogPath EQ '' then
|
||||||
Error_Services('Add', 'Log path not found in the ' : Service : ' service.')
|
Error_Services('Add', 'Log path not found in the ' : Service : ' service.')
|
||||||
end
|
end
|
||||||
end else
|
end else
|
||||||
Error_Services('Add', 'objLog argument was missing from the ' : Service : ' service.')
|
Error_Services('Add', 'objLog argument was missing from the ' : Service : ' service.')
|
||||||
end
|
end
|
||||||
|
|
||||||
Response = LogPath
|
Response = LogPath
|
||||||
|
|
||||||
end service
|
end service
|
||||||
|
|
||||||
|
|
||||||
@ -240,20 +263,20 @@ end service
|
|||||||
// path to where the log file is located.
|
// path to where the log file is located.
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------------------------
|
||||||
Service GetLogFileName(objLog)
|
Service GetLogFileName(objLog)
|
||||||
|
|
||||||
LogFileName = ''
|
LogFileName = ''
|
||||||
|
|
||||||
If objLog NE '' then
|
If objLog NE '' then
|
||||||
LogFileName = Memory_Services('GetValue', objLog : '*LogFileName', '', '', ServiceModule)
|
LogFileName = Memory_Services('GetValue', objLog : '*LogFileName', '', '', ServiceModule)
|
||||||
If LogFileName EQ '' then
|
If LogFileName EQ '' then
|
||||||
Error_Services('Add', 'Log file name not found in the ' : Service : ' service.')
|
Error_Services('Add', 'Log file name not found in the ' : Service : ' service.')
|
||||||
end
|
end
|
||||||
end else
|
end else
|
||||||
Error_Services('Add', 'objLog argument was missing from the ' : Service : ' service.')
|
Error_Services('Add', 'objLog argument was missing from the ' : Service : ' service.')
|
||||||
end
|
end
|
||||||
|
|
||||||
Response = LogFileName
|
Response = LogFileName
|
||||||
|
|
||||||
end service
|
end service
|
||||||
|
|
||||||
|
|
||||||
@ -265,20 +288,20 @@ end service
|
|||||||
// Returns the full path for the log file associated with the indicated log object handle.
|
// Returns the full path for the log file associated with the indicated log object handle.
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------------------------
|
||||||
Service GetLogFullPath(objLog)
|
Service GetLogFullPath(objLog)
|
||||||
|
|
||||||
LogFullPath = ''
|
LogFullPath = ''
|
||||||
|
|
||||||
If objLog NE '' then
|
If objLog NE '' then
|
||||||
LogFullPath = Memory_Services('GetValue', objLog : '*LogFullPath', '', '', ServiceModule)
|
LogFullPath = Memory_Services('GetValue', objLog : '*LogFullPath', '', '', ServiceModule)
|
||||||
If LogFullPath EQ '' then
|
If LogFullPath EQ '' then
|
||||||
Error_Services('Add', 'Log full path not found in the ' : Service : ' service.')
|
Error_Services('Add', 'Log full path not found in the ' : Service : ' service.')
|
||||||
end
|
end
|
||||||
end else
|
end else
|
||||||
Error_Services('Add', 'objLog argument was missing from the ' : Service : ' service.')
|
Error_Services('Add', 'objLog argument was missing from the ' : Service : ' service.')
|
||||||
end
|
end
|
||||||
|
|
||||||
Response = LogFullPath
|
Response = LogFullPath
|
||||||
|
|
||||||
end service
|
end service
|
||||||
|
|
||||||
|
|
||||||
@ -290,20 +313,20 @@ end service
|
|||||||
// Returns the delimiter to use to separate each row in the log.
|
// Returns the delimiter to use to separate each row in the log.
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------------------------
|
||||||
Service GetRowDelimiter(objLog)
|
Service GetRowDelimiter(objLog)
|
||||||
|
|
||||||
RowDelimiter = ''
|
RowDelimiter = ''
|
||||||
|
|
||||||
If objLog NE '' then
|
If objLog NE '' then
|
||||||
RowDelimiter = Memory_Services('GetValue', objLog : '*RowDelimiter', '', '', ServiceModule)
|
RowDelimiter = Memory_Services('GetValue', objLog : '*RowDelimiter', '', '', ServiceModule)
|
||||||
If RowDelimiter EQ '' then
|
If RowDelimiter EQ '' then
|
||||||
Error_Services('Add', 'Row delimiter not found in the ' : Service : ' service.')
|
Error_Services('Add', 'Row delimiter not found in the ' : Service : ' service.')
|
||||||
end
|
end
|
||||||
end else
|
end else
|
||||||
Error_Services('Add', 'objLog argument was missing from the ' : Service : ' service.')
|
Error_Services('Add', 'objLog argument was missing from the ' : Service : ' service.')
|
||||||
end
|
end
|
||||||
|
|
||||||
Response = RowDelimiter
|
Response = RowDelimiter
|
||||||
|
|
||||||
end service
|
end service
|
||||||
|
|
||||||
|
|
||||||
@ -315,20 +338,20 @@ end service
|
|||||||
// Returns the delimiter to use to separate each column in the log.
|
// Returns the delimiter to use to separate each column in the log.
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------------------------
|
||||||
Service GetColumnDelimiter(objLog)
|
Service GetColumnDelimiter(objLog)
|
||||||
|
|
||||||
ColumnDelimiter = ''
|
ColumnDelimiter = ''
|
||||||
|
|
||||||
If objLog NE '' then
|
If objLog NE '' then
|
||||||
ColumnDelimiter = Memory_Services('GetValue', objLog : '*ColumnDelimiter', '', '', ServiceModule)
|
ColumnDelimiter = Memory_Services('GetValue', objLog : '*ColumnDelimiter', '', '', ServiceModule)
|
||||||
If ColumnDelimiter EQ '' then
|
If ColumnDelimiter EQ '' then
|
||||||
Error_Services('Add', 'Column delimiter not found in the ' : Service : ' service.')
|
Error_Services('Add', 'Column delimiter not found in the ' : Service : ' service.')
|
||||||
end
|
end
|
||||||
end else
|
end else
|
||||||
Error_Services('Add', 'objLog argument was missing from the ' : Service : ' service.')
|
Error_Services('Add', 'objLog argument was missing from the ' : Service : ' service.')
|
||||||
end
|
end
|
||||||
|
|
||||||
Response = ColumnDelimiter
|
Response = ColumnDelimiter
|
||||||
|
|
||||||
end service
|
end service
|
||||||
|
|
||||||
|
|
||||||
@ -340,17 +363,17 @@ end service
|
|||||||
// Returns the column headers that should be in the log.
|
// Returns the column headers that should be in the log.
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------------------------
|
||||||
Service GetColumnHeaders(objLog)
|
Service GetColumnHeaders(objLog)
|
||||||
|
|
||||||
ColumnHeaders = ''
|
ColumnHeaders = ''
|
||||||
|
|
||||||
If objLog NE '' then
|
If objLog NE '' then
|
||||||
ColumnHeaders = Memory_Services('GetValue', objLog : '*ColumnHeaders', '', '', ServiceModule)
|
ColumnHeaders = Memory_Services('GetValue', objLog : '*ColumnHeaders', '', '', ServiceModule)
|
||||||
end else
|
end else
|
||||||
Error_Services('Add', 'objLog argument was missing from the ' : Service : ' service.')
|
Error_Services('Add', 'objLog argument was missing from the ' : Service : ' service.')
|
||||||
end
|
end
|
||||||
|
|
||||||
Response = ColumnHeaders
|
Response = ColumnHeaders
|
||||||
|
|
||||||
end service
|
end service
|
||||||
|
|
||||||
|
|
||||||
@ -362,17 +385,17 @@ end service
|
|||||||
// Returns the column widths that should be used to truncate or pad each column in the log.
|
// Returns the column widths that should be used to truncate or pad each column in the log.
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------------------------
|
||||||
Service GetColumnWidths(objLog)
|
Service GetColumnWidths(objLog)
|
||||||
|
|
||||||
ColumnWidths = ''
|
ColumnWidths = ''
|
||||||
|
|
||||||
If objLog NE '' then
|
If objLog NE '' then
|
||||||
ColumnWidths = Memory_Services('GetValue', objLog : '*ColumnWidths', '', '', ServiceModule)
|
ColumnWidths = Memory_Services('GetValue', objLog : '*ColumnWidths', '', '', ServiceModule)
|
||||||
end else
|
end else
|
||||||
Error_Services('Add', 'objLog argument was missing from the ' : Service : ' service.')
|
Error_Services('Add', 'objLog argument was missing from the ' : Service : ' service.')
|
||||||
end
|
end
|
||||||
|
|
||||||
Response = ColumnWidths
|
Response = ColumnWidths
|
||||||
|
|
||||||
end service
|
end service
|
||||||
|
|
||||||
|
|
||||||
@ -384,18 +407,18 @@ end service
|
|||||||
// Returns the flag to indicate whether column values should be quoted or not.
|
// Returns the flag to indicate whether column values should be quoted or not.
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------------------------
|
||||||
Service GetQuoteValues(objLog)
|
Service GetQuoteValues(objLog)
|
||||||
|
|
||||||
QuoteValues = ''
|
QuoteValues = ''
|
||||||
|
|
||||||
If objLog NE '' then
|
If objLog NE '' then
|
||||||
QuoteValues = Memory_Services('GetValue', objLog : '*QuoteValues', '', '', ServiceModule)
|
QuoteValues = Memory_Services('GetValue', objLog : '*QuoteValues', '', '', ServiceModule)
|
||||||
If QuoteValues NE True$ then QuoteValues = False$
|
If QuoteValues NE True$ then QuoteValues = False$
|
||||||
end else
|
end else
|
||||||
Error_Services('Add', 'objLog argument was missing from the ' : Service : ' service.')
|
Error_Services('Add', 'objLog argument was missing from the ' : Service : ' service.')
|
||||||
end
|
end
|
||||||
|
|
||||||
Response = QuoteValues
|
Response = QuoteValues
|
||||||
|
|
||||||
end service
|
end service
|
||||||
|
|
||||||
|
|
||||||
@ -407,57 +430,57 @@ end service
|
|||||||
// Creates (or clears out) a log file associated with the indicated log object handle.
|
// Creates (or clears out) a log file associated with the indicated log object handle.
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------------------------
|
||||||
Service CreateLogFile(objLog)
|
Service CreateLogFile(objLog)
|
||||||
|
|
||||||
If objLog NE '' then
|
If objLog NE '' then
|
||||||
LogFullPath = Logging_Services('GetLogFullPath', objLog)
|
LogFullPath = Logging_Services('GetLogFullPath', objLog)
|
||||||
If Error_Services('NoError') then
|
If Error_Services('NoError') then
|
||||||
Status() = 0
|
Status() = 0
|
||||||
OSWrite '' to LogFullPath
|
OSWrite '' to LogFullPath
|
||||||
Status = Status()
|
Status = Status()
|
||||||
If Status GT 0 then
|
If Status GT 0 then
|
||||||
Error_Services('Add', 'Unable to clear ' : LogFullPath : ' in the ' : Service : ' service.')
|
Error_Services('Add', 'Unable to clear ' : LogFullPath : ' in the ' : Service : ' service.')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end else
|
end else
|
||||||
Error_Services('Add', 'objLog argument was missing from the ' : Service : ' service.')
|
Error_Services('Add', 'objLog argument was missing from the ' : Service : ' service.')
|
||||||
end
|
end
|
||||||
|
|
||||||
end service
|
End Service
|
||||||
|
|
||||||
|
|
||||||
Service CleanLogFolders(NumDays)
|
Service CleanLogFolders(NumDays)
|
||||||
|
|
||||||
FileExclusionList = 'Canary.txt':@VM:'Canary.vbs'
|
FileExclusionList = 'Canary.txt':@VM:'Canary.vbs'
|
||||||
AppRootPath = Environment_Services('GetApplicationRootPath')
|
AppRootPath = Environment_Services('GetApplicationRootPath')
|
||||||
LogPath = AppRootPath : '\LogFiles\'
|
LogPath = AppRootPath : '\LogFiles\'
|
||||||
SetInitDirOptions("D")
|
SetInitDirOptions("D")
|
||||||
InitDir LogPath:'*'
|
InitDir LogPath:'*'
|
||||||
FolderList = DirList()
|
FolderList = DirList()
|
||||||
// Remove . directory listing
|
// Remove . directory listing
|
||||||
FolderList = Delete(FolderList, 1, 0, 0)
|
FolderList = Delete(FolderList, 1, 0, 0)
|
||||||
// Remove .. directory listing
|
// Remove .. directory listing
|
||||||
FolderList = Delete(FolderList, 1, 0, 0)
|
FolderList = Delete(FolderList, 1, 0, 0)
|
||||||
Today = Date()
|
Today = Date()
|
||||||
SetInitDirOptions("")
|
SetInitDirOptions("")
|
||||||
For each Folder in FolderList
|
For each Folder in FolderList
|
||||||
FolderPath = LogPath:Folder:'\'
|
FolderPath = LogPath:Folder:'\'
|
||||||
InitDir FolderPath:'*'
|
InitDir FolderPath:'*'
|
||||||
FileList = DirList()
|
FileList = DirList()
|
||||||
If FileList NE '' then
|
If FileList NE '' then
|
||||||
For each Filename in FileList
|
For each Filename in FileList
|
||||||
Locate FileName in FileExclusionList using @VM setting vPos else
|
Locate FileName in FileExclusionList using @VM setting vPos else
|
||||||
FilePath = FolderPath:Filename
|
FilePath = FolderPath:Filename
|
||||||
FileInfo = Dir(FilePath)
|
FileInfo = Dir(FilePath)
|
||||||
LastWriteDate = FileInfo<2>
|
LastWriteDate = FileInfo<2>
|
||||||
FileAge = Today - LastWriteDate
|
FileAge = Today - LastWriteDate
|
||||||
If FileAge GT NumDays then
|
If FileAge GT NumDays then
|
||||||
OSDelete FilePath
|
OSDelete FilePath
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Next Filename
|
Next Filename
|
||||||
end
|
end
|
||||||
Next Folder
|
Next Folder
|
||||||
|
|
||||||
end service
|
end service
|
||||||
|
|
||||||
|
|
||||||
@ -466,40 +489,50 @@ end service
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
EmailMessage:
|
EmailMessage:
|
||||||
|
|
||||||
Done = False$
|
Done = False$
|
||||||
Error = False$
|
Error = False$
|
||||||
MsgSent = ''
|
MsgSent = ''
|
||||||
|
|
||||||
ConfigFile = ''
|
ConfigFile = ''
|
||||||
ConfigFile<1> = SendUsing_Port$
|
ConfigFile<1> = SendUsing_Port$
|
||||||
ConfigFile<2> = ''
|
ConfigFile<2> = ''
|
||||||
ConfigFile<3> = 25 ; // Server port
|
ConfigFile<3> = 25 ; // Server port
|
||||||
*ConfigFile<4> = 'appmail.eu.infineon.com' ; // Mail server
|
*ConfigFile<4> = 'appmail.eu.infineon.com' ; // Mail server
|
||||||
ConfigFile<4> = 'mailrelay-external.infineon.com' ; // Mail server
|
ConfigFile<4> = 'mailrelay-external.infineon.com' ; // Mail server
|
||||||
ConfigFile<5> = True$ ; // Authenticate
|
ConfigFile<5> = True$ ; // Authenticate
|
||||||
ConfigFile<6> = 'oinotify@infineon.com' ; // Username
|
ConfigFile<6> = 'oinotify@infineon.com' ; // Username
|
||||||
ConfigFile<7> = 'oinotify1' ; // Password
|
ConfigFile<7> = 'oinotify1' ; // Password
|
||||||
ConfigFile<8> = False$ ; // Use SSL
|
ConfigFile<8> = False$ ; // Use SSL
|
||||||
|
|
||||||
If EmailMessage EQ '' then
|
If EmailMessage EQ '' then
|
||||||
EmailMessage = LogData : \0D0A0D0A\ : RetStack()<2>
|
EmailMessage = LogData : \0D0A0D0A\ : RetStack()<2>
|
||||||
end else
|
end else
|
||||||
EmailMessage := \0D0A0D0A\ : LogData : \0D0A0D0A\ : RetStack()<2>
|
EmailMessage := \0D0A0D0A\ : LogData : \0D0A0D0A\ : RetStack()<2>
|
||||||
end
|
end
|
||||||
|
|
||||||
SentFrom = ''
|
SentFrom = ''
|
||||||
SentTo = ''
|
SentTo = ''
|
||||||
Message = ''
|
Message = ''
|
||||||
Message<1> = 'AppendLog Message' ; // Subject
|
Message<1> = 'AppendLog Message' ; // Subject
|
||||||
Message<2> = 'oinotify@infineon.com' ; // From (email address)
|
Message<2> = 'oinotify@infineon.com' ; // From (email address)
|
||||||
Message<3> = EmailAddresses ; // Send to (email address)
|
Message<3> = EmailAddresses ; // Send to (email address)
|
||||||
Message<5> = '' ; // Blind Carbon Copy (email address)
|
Message<5> = '' ; // Blind Carbon Copy (email address)
|
||||||
Message<6> = '' ; // Reply To (email address)
|
Message<6> = '' ; // Reply To (email address)
|
||||||
Message<7> = 'TEXT' ; // Content Type (TEXT or HTML)
|
Message<7> = 'TEXT' ; // Content Type (TEXT or HTML)
|
||||||
Message<8> = EmailMessage ; // Content / Body
|
Message<8> = EmailMessage ; // Content / Body
|
||||||
Message<9> = '' ; // Attachment(s) (path to file name(s))
|
Message<9> = '' ; // Attachment(s) (path to file name(s))
|
||||||
|
|
||||||
Result = SRP_Send_Mail(Message, ConfigFile)
|
Result = SRP_Send_Mail(Message, ConfigFile)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
CreateDependentDirectories:
|
||||||
|
|
||||||
|
CreatePath = True$
|
||||||
|
DirectoryCreated = RTI_OS_Directory( 'CREATE', LogPath, CreatePath)
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user