Skip to content

cLogs Methods Reference

📝 Logging Methods

Data

Logs content (default property, supports chainable calls).

vb
Public Function Data(ByVal LogContent As String, Optional ByVal LogTitle As String, Optional LogLevel As EnumLogLevel = LvInfo) As cLogs

Parameters:

  • LogContent - Log content
  • LogTitle - Log title (optional)
  • LogLevel - Log level (default LvInfo)

Returns: Returns self instance for chainable calls

Example:

vb
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.

vb
Public Function DataLine(ByVal LogContent As String, Optional ByVal LogTitle As String, Optional LogLevel As EnumLogLevel = LvInfo) As cLogs

Description: Auto adds line break vbCrLf at end of content

Example:

vb
Log.DataLine "Error details:"
Log.DataLine "  File: Form1.frm"
Log.DataLine "  Line: 156"
Log.Save

Save

Writes cached logs to file.

vb
Public Function Save() As cLogs

Description:

  • Writes all cached logs from CacheDatas to file
  • Decides filename based on LogFileNameRule
  • Auto creates directory structure
  • Clears cache

Example:

vb
' 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.

vb
Public Function ToFormView(LogStr As String, Optional LogLevel As EnumLogLevel) As String

Prerequisite: Must set FormListBox property

Example:

vb
' 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.

vb
Public Function ToDbgView(LogStr As String, Optional LogLevel As EnumLogLevel) As String

Description: Uses Windows API OutputDebugString to output

DbgView Filter Settings:

Include: VBMAN LOG DATA*

Example:

vb
Log.SendToDbgView = True
Log.Data "Debug info", "DEBUG", LvDebugger
' DbgView shows: VBMAN LOG DATA:::[time] [DEBUGGER] DEBUG Debug info

ToWebView

Outputs to web remote debugging.

vb
Public Function ToWebView(LogStr As String, Optional LogLevel As EnumLogLevel) As String

Prerequisite: Must set WebUserCode

Usage Steps:

  1. Visit http://log.vb6.pro to get user code
  2. Set Log.WebUserCode = "your-code"
  3. Enable Log.SendToWebView = True
  4. View logs in real-time on web

Example:

vb
Log.WebUserCode = "abc123"
Log.SendToWebView = True
Log.Data "Remote debug info"

🎛️ Control Methods

View

Controls log viewer window show/hide (chainable).

vb
Public Function View(Value As Boolean) As cLogs

Example:

vb
Log.View(True).Data("Show window and log").Save

HostApp

Sets host application object (chainable).

vb
Public Function HostApp(o As Object) As cLogs

Description: Used to get program path, defaults to auto-set App object

Example:

vb
Log.HostApp(App).Data("Log").Save

📊 Log Levels

EnumLogLevel Enum

LevelValueConstantDescription
LvInfo0INFOGeneral info
LvWarn1WARNWarning info
LvDanger2DANGERDanger info
LvError3ERRORError info
LvDebugger4DEBUGGERDebug info
LvCustom5CUSTOMCustom level

Log Level Control

vb
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.Save

Last Updated: 2026-05-17

VB6 and LOGO copyright of Microsoft Corporation