Coder Social home page Coder Social logo

vba-log's Introduction

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

Logger.LogDebug "Howdy!"
' -> does nothing because logging is disabled by default

Logger.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).

vba-log's People

Contributors

timhall avatar

Watchers

Claudiu Margarint avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.