Jump to content
LordJashin

OSI Logging System Revamp! TOSILog type, among other things

Recommended Posts

With that issue with the multi lining I had put this on hold till I got that sorted out. But now its all done, so I continued, and finished the work on the logging system. So now it is closer to being perfect now.

 

Features:

- Multi Line support

- Autologging with OSILog variable. Custom (Folder Path, New Folder, Log Name, Log File type).

- Write full log to debug box

- Auto Screenshot Saving with OSILog variable. Custom (Folder Path, New Folder, Save Name)

- OSILog Client Only variable, if you want screenshots of only the client

- If log or screenshot name already exists appends - 1, or - 2, etc.

- New functions to AutoSave either a log or screenshot whenever you call the appropriate function.

 

 

New var OSILog: TOSILog;. OSILog variable.

 

[scar]

{=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

type TOSILog

Contributors: LordJashin

Description: For All OSI's logging functions in Divi\Misc\Logging.scar

Date Created: October 16th, 2012. By LordJashin.

Last Modified: October 21st, 2012. By LordJashin.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=}

 

type TOSILog = record

Script: TOSIScriptInfo;

Log: TStrArray;

AutoLog: Boolean;

AutoLogName: string;

AutoLogFolderPath: string;

AutoLogFileType: string;

AutoLogNewFolder: string;

AutoScreen: Boolean;

AutoScreenFolderPath: string;

AutoScreenClientOnly: Boolean;

AutoScreenName: string;

AutoScreenNewFolder: string;

end;

 

var

OSILog: TOSILog;

[/scar]

 

New functions:

[scar]

procedure OSI_SetupAutoLog(FolderPath, FileType, NewFolder, LogName: string);

procedure OSI_SetupAutoScreenSave(FolderPath, SaveName, NewFolder: string; ClientOnly: Boolean);

function OSI_AutoSaveScreen: Boolean;

function OSI_AutoSaveLog: Boolean;

procedure OSI_WriteLog;

function StrExplodeMulti(d: TStrArray; str: string): TStrArray;

[/scar]

 

OSI_WriteLog - Will write the whole log to the debug box;

OSI_SetupAutoLog - Sets up the variables in OSILog variable for Auto logging

OSI_SetupAutoScreenSave - Sets up the variables in OSILog variable for Auto Screenshot saving

OSI_AutoSaveScreen - Will auto save the screen for you, if Auto Screenshot saving is enabled

OSI_AutoSaveLog - Will auto save OSILog log for you, if Auto logging is enabled

StrExplodeMulti - Will explode a string by multiple Delimiters or separators into a TStrArray.

 

Updated Odd & Even for 3.36

Other type I added but doesn't do anything inside OSI yet:

 

[scar]

{=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

type TOSIScriptInfo

Contributors: LordJashin

Description: Hold info for your script! Will be used in logging eventually

Date Created: October 16th, 2012. By LordJashin.

Last Modified: October 16th, 2012. By LordJashin.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=}

 

type TOSIScriptInfo = record

Name, Version, Author, Description, Created, LastUpdated: string;

end;

[/scar]

 

Here's an example using the latest features:

 

[scar]

program TestingFeatures;

{$I OSI/OSI.scar}

 

const

ClientOnly = False; // Save screenshots of client only and not full desktop?

 

procedure SetupIncludes;

begin

OSI_SetupAutoLog(LogsPath, 'txt', 'TestFolder', 'TestName');

OSI_SetupAutoScreenSave(LogsPath, 'TestFolder', 'TestName', ClientOnly);

SetupOSI;

end;

 

procedure ScriptTerminate;

begin

FreeOSI;

end;

 

begin

SetupIncludes;

end.

[/scar]

 

Testing file.

 

Possible features might add in future:

- Custom (auto logging/auto screenshot saving) times, dates, formats, etc.

- Custom formats for Screen shots (bmp, png, etc).

- Custom options for OSILog log's header

- Add OSI Script Info into the header

 

Possible features for OSI in future:

- More Exception handling & maybe more try..except..finally blocks

- logging of exceptions more, hopefully more information about exceptions too

Edited by LordJashin
Link to comment
Share on other sites

New error handling added:

 

[scar]{=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

procedure HandleOSIException;

Contributors: LordJashin

Description: Used in SetupOSI to handle any errors! OSIExceptionThrown is set

Date Created: October 21st, 2012. By LordJashin.

Last Modified: October 21st, 2012. By LordJashin.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=}

 

var

OSIExceptionThrown: Boolean;

 

procedure HandleOSIException;

var

s: string;

begin

s := ExceptionToString(ExceptionType, ExceptionParam) + #13#10 +

'***WARNING***' + #13#10 +

'Failed to load! An Error has occurred!' + #13#10 +

'Try restarting SCAR Divi, SMART, or Re-installing OSI' + #13#10 +

'If problems persist post a thread on the forums at http://www.scar-divi.com' + #13#10 +

'Terminating Script!';

OSI_WriteAndLog(s);

OSIExceptionThrown := True;

ShowMessage(s);

OSI_AutoSaveLog;

RaiseLastException;

TerminateScript;

end;[/scar]

 

Used in SetupOSI function now:

 

[scar] except

HandleOSIException;

finally

if not OSIExceptionThrown then

begin

IsOSISetup := True;

OSI_WriteAndLog('Successfully Setup!');

end;

end;[/scar]

 

So if an error pops up, everything will terminate, and you will get a ShowMessage and writelns about it..

 

 

Now that I think about it. Could add some Forms, functionality, and build it in too. Create my own little record...then use it instead of showmessage. But its fine for now I guess. Create like a little help form lols.

Edited by LordJashin
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
  • Create New...