https://github.com/VBA-tools/VBA-Log
Logging for VBA
https://github.com/VBA-tools/VBA-Log
Last synced: 4 months ago
JSON representation
Logging for VBA
- Host: GitHub
- URL: https://github.com/VBA-tools/VBA-Log
- Owner: VBA-tools
- License: mit
- Created: 2015-09-07T01:14:17.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-04-29T16:07:00.000Z (almost 9 years ago)
- Last Synced: 2024-11-07T23:22:51.542Z (5 months ago)
- Language: Visual Basic
- Size: 157 KB
- Stars: 95
- Watchers: 21
- Forks: 47
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - VBA-tools/VBA-Log - Logging for VBA (Visual Basic)
README
# VBA-Log
Logging helpers for VBA. Logs to Immediate Window by default (`ctrl + g`), but can attach multiple loggers with callbacks.
Tested in Windows Excel 2013 32-bit and 64-bit and Excel for Mac 2011, but should apply to Windows Excel 2007+.
# Example
```VB.net
Logger.LogDebug "Howdy!"
' -> does nothing because logging is disabled by defaultLogger.LogEnabled = True
' -> Log all levels (Trace, Debug, Info, Warn, Error)Logger.LogThreshold = 3
' -> Log levels >= 3 (Info, Warn, and Error)Logger.LogTrace "Start of logging"
Logger.LogDebug "Logging has started"
Logger.LogInfo "Logged with VBA-Log"
Logger.LogWarn "Watch out!", "ModuleName.SubName"
Logger.LogError "Something went wrong", "ClassName.FunctionName", Err.Number' Attach alternative logging function(s)
Public Sub LogFile(Level As Long, Message As String, From As String)
' ...
End Sub' Log to single function
Logger.LogCallback = "LogFile"Public Sub LogWorkbook(Level As Long, Message As String, From As String)
' ...
End Sub' Log to multiple functions
Logger.LogCallback = Array("LogFile", "LogWorkbook")
```For applications that don't support `Application.Run` (e.g. Access), there is a note in `Logger.Log` for where to put your custom logging function (if desired).