cLogs Methods Reference
📝 Logging Methods
Data
Logs content (default property, supports chainable calls).
Public Function Data(ByVal LogContent As String, Optional ByVal LogTitle As String, Optional LogLevel As EnumLogLevel = LvInfo) As cLogsParameters:
LogContent- Log contentLogTitle- Log title (optional)LogLevel- Log level (default LvInfo)
Returns: Returns self instance for chainable calls
Example:
Dim Log As New cLogs
' Basic usage
Log.Data "System started"
' With title
Log.Data "Connection successful", "Database"
' Specify level
Log.Data "Memory low", "System", LvWarn
' Chainable call
Log.Data("First").Data("Second").Data("Third")DataLine
Logs content with line break.
Public Function DataLine(ByVal LogContent As String, Optional ByVal LogTitle As String, Optional LogLevel As EnumLogLevel = LvInfo) As cLogsDescription: Auto adds line break vbCrLf at end of content
Example:
Log.DataLine "Error details:"
Log.DataLine " File: Form1.frm"
Log.DataLine " Line: 156"
Log.SaveSave
Writes cached logs to file.
Public Function Save() As cLogsDescription:
- Writes all cached logs from
CacheDatasto file - Decides filename based on
LogFileNameRule - Auto creates directory structure
- Clears cache
Example:
' Batch log then save once
Log.Data "Event 1"
Log.Data "Event 2"
Log.Data "Event 3"
Log.Save
' Chainable写法
Log.Data("Event 1").Data("Event 2").Data("Event 3").Save🔄 Channel Output Methods
ToFormView
Outputs to form ListBox control.
Public Function ToFormView(LogStr As String, Optional LogLevel As EnumLogLevel) As StringPrerequisite: Must set FormListBox property
Example:
' Set target ListBox
Set Log.FormListBox = Form1.List1
Log.FormListBoxMaxItem = 500 ' Max items to keep
' Output log
Log.ToFormView "Real-time message"
' Or auto trigger after Data (if SendToFormView=True)
Log.SendToFormView = True
Log.Data "Auto output to ListBox"ToDbgView
Outputs to DbgView tool.
Public Function ToDbgView(LogStr As String, Optional LogLevel As EnumLogLevel) As StringDescription: Uses Windows API OutputDebugString to output
DbgView Filter Settings:
Include: VBMAN LOG DATA*Example:
Log.SendToDbgView = True
Log.Data "Debug info", "DEBUG", LvDebugger
' DbgView shows: VBMAN LOG DATA:::[time] [DEBUGGER] DEBUG Debug infoToWebView
Outputs to web remote debugging.
Public Function ToWebView(LogStr As String, Optional LogLevel As EnumLogLevel) As StringPrerequisite: Must set WebUserCode
Usage Steps:
- Visit http://log.vb6.pro to get user code
- Set
Log.WebUserCode = "your-code" - Enable
Log.SendToWebView = True - View logs in real-time on web
Example:
Log.WebUserCode = "abc123"
Log.SendToWebView = True
Log.Data "Remote debug info"🎛️ Control Methods
View
Controls log viewer window show/hide (chainable).
Public Function View(Value As Boolean) As cLogsExample:
Log.View(True).Data("Show window and log").SaveHostApp
Sets host application object (chainable).
Public Function HostApp(o As Object) As cLogsDescription: Used to get program path, defaults to auto-set App object
Example:
Log.HostApp(App).Data("Log").Save📊 Log Levels
EnumLogLevel Enum
| Level | Value | Constant | Description |
|---|---|---|---|
| LvInfo | 0 | INFO | General info |
| LvWarn | 1 | WARN | Warning info |
| LvDanger | 2 | DANGER | Danger info |
| LvError | 3 | ERROR | Error info |
| LvDebugger | 4 | DEBUGGER | Debug info |
| LvCustom | 5 | CUSTOM | Custom level |
Log Level Control
Dim Log As New cLogs
' Set control level (only log WARN and above)
Log.LogLevelControl = LvWarn
Log.Data "General info", , LvInfo ' Ignored (0 < 1)
Log.Data "Warning info", , LvWarn ' Logged (1 >= 1)
Log.Data "Error info", , LvError ' Logged (3 >= 1)
Log.SaveLast Updated: 2026-05-17