-
-
Notifications
You must be signed in to change notification settings - Fork 493
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Log to file as well as immediate window #215
base: master
Are you sure you want to change the base?
Conversation
This PR adds functionality to write the same log messages to a file as well as to the VBA immediate window.
For performance reasons the log file is held open unless the project is reset. This commit adds a method to close the log file in order to allow programmatic changes to the log file location.
Public Sub without args are available to run as a macro from the Outlook UI.
Avoid having separate Debug.Print statements in order to print debugging regardless of EnableLogging or file logging.
|
||
FileOpenError: | ||
Debug.Print "ERROR: Unable to open logfile '" & LogFile & "' for Append Write: Error " & Err.Number & ": " & Err.Description | ||
LogFileNumber = -100 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea here is not to issue excessive numbers of these errors to the immediate window - but upon reflection I am not sure this is such a good idea - or perhaps only if normal EnableLogging is true.
On reflection, I wonder whether the Debug.Print logic should be included in the LogWrite routine. Also, I wonder if we should write the time-stamp to the immediate window also - and if so whether this should be through a separate boolean Public property. |
Hi @Sophist-UK rather than include the file logging with VBA-Web, I'd recommend replacing the current logging with VBA-Log and then creating a standalone file logger that can be used with it. Also, I know you've had some qualms with Example: Dim FileLogger = New FileLog
Logger.LogFile = "..."
WebHelpers.LogInstance = FileLogger
WebHelpers.LogThreshold = 4
' -> CallByName FileLogger, "Log", vbMethod, Level, Message, From |
Here's the related issue: VBA-tools/VBA-Log#1 |
In principle I agree, however VBA-Log uses Application.Run for the callbacks which makes it inelligent but also incompatible with some Office applications. And that would have a knock on effect on VBA-Web compatibility. BUT ... if we can merge the functionality i.e. to provide file logging as a standard part of VBA-Log which does not rely on callbacks, then we could have the best of both worlds. That said, a change to VBA-Log would seem to be something for VBA-Web v5, and o perhaps we can include these changes in the interim in v4. |
BTW, I cannot believe what VBA-Web has enabled me to achieve in Outlook. Happy to tell you offline if you want to correspond privately. (sophist at sodalis dot co dot uk) |
This PR adds functionality to write the same log messages to a file as well as to the VBA immediate window.