![]() |
Bearsampp 2026.7.11
|
Static Public Member Functions | |
| static | debug ($data, $file=null) |
| static | error ($data, $file=null) |
| static | flush () |
| static | flushAsyncQueue () |
| static | getAsyncQueueDir () |
| static | getAsyncQueueSize () |
| static | getBufferSize () |
| static | getStats () |
| static | info ($data, $file=null) |
| static | init () |
| static | initClass ($classInstance) |
| static | isAsyncEnabled () |
| static | processAsyncQueue () |
| static | reloadClass ($classInstance) |
| static | reset () |
| static | separator () |
| static | setAsyncEnabled ($enabled) |
| static | setBufferSize ($size) |
| static | trace ($data, $file=null) |
| static | warning ($data, $file=null) |
Data Fields | |
| const | DEBUG = 'DEBUG' |
| const | ERROR = 'ERROR' |
| const | INFO = 'INFO' |
| const | TRACE = 'TRACE' |
| const | WARNING = 'WARNING' |
Static Private Member Functions | |
| static | checkVerbosityAndAdjustAsync () |
| static | cleanupStaleAsyncQueue ($maxAge) |
| static | initializeAsyncQueue () |
| static | queueAsyncWrite ($file, $content) |
| static | write ($data, $type, $file=null) |
Static Private Attributes | |
| static | $asyncEnabled = true |
| static | $asyncQueueDir = null |
| static | $logBuffer = [] |
| static | $logBufferSize = 50 |
| static | $logStats |
| static | $maxAsyncQueueBatch = 5 |
| static | $shutdownRegistered = false |
Log class providing static logging methods with buffered and asynchronous I/O.
Supports five log levels (TRACE, DEBUG, INFO, WARNING, ERROR), a separator utility, class-lifecycle helpers, and a configurable write buffer to reduce file-system pressure. Also supports asynchronous logging to decouple I/O operations from the main process.
Call Log\init() once during bootstrap (after globals are available) to register the shutdown flush handler and initialize async logging.
Usage:
Definition at line 29 of file class.log.php.
|
staticprivate |
Check logging verbosity and adjust async settings accordingly. Disables async when TRACE level is enabled for real-time log visibility. Also optimizes buffer size for better responsiveness during debugging.
Definition at line 94 of file class.log.php.
References $bearsamppConfig, Config\VERBOSE_DEBUG, and Config\VERBOSE_TRACE.
Referenced by init().
|
staticprivate |
Clean up stale queue files that weren't processed. Prevents queue directory from filling up with old entries.
| int | $maxAge | Maximum age in seconds |
Definition at line 437 of file class.log.php.
Referenced by processAsyncQueue().
|
static |
Logs a DEBUG-level message.
| mixed | $data | |
| string | null | $file |
Definition at line 616 of file class.log.php.
References write().
Referenced by ActionCheckVersion\__construct(), ActionQuit\__construct(), Action\call(), Path\changePath(), BinApache\changePort(), BinMailpit\changePort(), BinMariadb\changePort(), BinMemcached\changePort(), BinMysql\changePort(), BinPostgresql\changePort(), BinXlight\changePort(), QuickPick\checkDownloadId(), ActionQuit\checkForOrphanedProcesses(), BinApache\checkPort(), BinMailpit\checkPort(), BinMariadb\checkPort(), BinMemcached\checkPort(), BinMysql\checkPort(), BinPostgresql\checkPort(), BinXlight\checkPort(), Csrf\cleanupExpiredTokens(), ActionQuit\cleanupTemporaryFiles(), Win32Native\countFilesFolders(), Win32Native\countFilesFoldersCOM(), Win32Native\createShortcut(), QuickPick\fetchAndUnzipModule(), Csrf\generateToken(), Registry\getAppBinsRegKey(), Win32Native\getDefaultBrowser(), Util\getFilesToScan(), HttpClient\getHeaders(), Util\getHeaders(), HttpClient\getHttpHeaders(), Util\getHttpHeaders(), Win32Native\getInstalledBrowsers(), HttpClient\getLatestVersion(), Util\getLatestVersion(), QuickPick\getModuleUrl(), Win32Native\getProcessList(), Win32Native\getServiceInfo(), Win32Native\getSpecialFolderPath(), QuickPick\getVersions(), BinPostgresql\handleNonPostgresUsage(), Win32Service\infos(), QuickPick\installModule(), Win32Native\killProcess(), Win32Native\listServices(), ModuleLoader\loadAsync(), ModuleLoader\loadSync(), QuickPick\logHeaders(), ActionQuit\performQuickCleanupVerification(), Action\process(), ActionQuit\processWindow(), QuickPick\rebuildQuickpickJson(), BinApache\refreshAlias(), BinApache\refreshConf(), BinApache\refreshVhosts(), QuickPick\regenerateMenuSafe(), Win32Native\registryDeleteKey(), Win32Native\registryDeleteValue(), Win32Native\registryExists(), Win32Native\registryGetValue(), Win32Native\registrySetValue(), Symlinks\safeRemoveSymlink(), ActionStartup\scanFolders(), Cache\set(), Cache\setDuration(), BinApache\setEnable(), BinMailpit\setEnable(), BinMariadb\setEnable(), BinMemcached\setEnable(), BinMysql\setEnable(), BinNodejs\setEnable(), BinPhp\setEnable(), BinPostgresql\setEnable(), BinXlight\setEnable(), ActionCheckVersion\showVersionOkMessageBox(), Win32Service\start(), BinApache\switchVersion(), BinMailpit\switchVersion(), BinMariadb\switchVersion(), BinMemcached\switchVersion(), BinMysql\switchVersion(), BinNodejs\switchVersion(), BinPhp\switchVersion(), BinPostgresql\switchVersion(), BinXlight\switchVersion(), Core\unzipFile(), AppPhpmyadmin\updateConfig(), AppPhppgadmin\updateConfig(), BinApache\updateConfig(), BinMailpit\updateConfig(), BinMariadb\updateConfig(), BinMemcached\updateConfig(), BinMysql\updateConfig(), BinNodejs\updateConfig(), BinPhp\updateConfig(), BinPostgresql\updateConfig(), BinXlight\updateConfig(), Module\updateConfig(), ToolGit\updateConfig(), QuickPick\updateModuleConfig(), Csrf\validateToken(), ActionQuit\verifyServicesStoppedAndCleanup(), ActionStartup\writeLog(), Batch\writeLog(), CommandRunner\writeLog(), Nssm\writeLog(), Registry\writeLog(), Win32Service\writeLog(), and WinBinder\writeLog().
|
static |
Logs an ERROR-level message. Errors bypass the buffer and are written immediately.
| mixed | $data | |
| string | null | $file |
Definition at line 650 of file class.log.php.
References write().
Referenced by ActionCheckVersion\__construct(), ActionLoading\__construct(), FiberModule\__construct(), Path\changePath(), BinApache\changePort(), BinMailpit\changePort(), BinMariadb\changePort(), BinMemcached\changePort(), BinMysql\changePort(), BinPostgresql\changePort(), BinXlight\changePort(), QuickPick\checkDownloadId(), ActionQuit\checkForOrphanedProcesses(), BinApache\checkPort(), BinMailpit\checkPort(), BinMariadb\checkPort(), BinMemcached\checkPort(), BinMysql\checkPort(), BinPostgresql\checkPort(), BinXlight\checkPort(), ActionQuit\cleanupTemporaryFiles(), Win32Native\countFilesFolders(), Win32Native\countFilesFoldersCOM(), OpenSsl\createCrt(), Symlinks\createModuleSymlink(), Win32Native\createShortcut(), ActionStartup\createSslCrts(), Symlinks\deleteCurrentSymlinks(), Util\deleteFolder(), OpenSsl\ensureMkcertExeExists(), OpenSsl\ensureRootCaExists(), OpenSsl\ensureSslDirExists(), QuickPick\fetchAndUnzipModule(), Win32Native\findProcessesByName(), UtilString\generateSecureBytes(), UtilString\generateSecureToken(), Csrf\generateToken(), HttpClient\getApiJson(), Util\getApiJson(), Core\getAppVersion(), Cache\getCacheIntegrityKey(), Core\getFileFromUrl(), HttpClient\getLatestVersion(), Util\getLatestVersion(), QuickPick\getModuleUrl(), Win32Native\getProcessInfo(), Win32Native\getProcessList(), QuickPick\getQuickpickJson(), Win32Native\getServiceInfo(), Win32Native\getSpecialFolderPath(), QuickPick\getVersions(), Splash\init(), BinMariadb\initData(), QuickPick\installModule(), Util\installService(), OpenSsl\isExpired(), Symlinks\isPathWithinAllowedBase(), Win32Native\killProcess(), Win32Native\listServices(), OpenSsl\makeRootCa(), ActionCheckVersion\processWindow(), UtilString\random(), OpenSsl\rebuildAllCerts(), Win32Native\registryDeleteKey(), Win32Native\registryDeleteValue(), Win32Native\registryExists(), Win32Native\registrySetValue(), AppPhpmyadmin\reload(), AppPhppgadmin\reload(), BinApache\reload(), BinMailpit\reload(), BinMariadb\reload(), BinMemcached\reload(), BinMysql\reload(), BinNodejs\reload(), BinPhp\reload(), BinPostgresql\reload(), BinXlight\reload(), ToolBruno\reload(), ToolComposer\reload(), ToolGhostscript\reload(), ToolGit\reload(), ToolNgrok\reload(), ToolPerl\reload(), ToolPowerShell\reload(), ToolPython\reload(), ToolRuby\reload(), OpenSsl\removeCrt(), Util\removeService(), Symlinks\safeRemoveSymlink(), Win32Service\start(), Util\startService(), Win32Service\stop(), TplAppReload\triggerReload(), Core\unzipFile(), AppPhpmyadmin\updateConfig(), AppPhppgadmin\updateConfig(), BinApache\updateConfig(), BinMailpit\updateConfig(), BinMariadb\updateConfig(), BinMemcached\updateConfig(), BinMysql\updateConfig(), BinNodejs\updateConfig(), BinPhp\updateConfig(), BinPostgresql\updateConfig(), BinXlight\updateConfig(), QuickPick\updateModuleConfig(), ActionQuit\verifyServicesStoppedAndCleanup(), ActionQuit\verifySymlinksRemoved(), FiberModule\wait(), ModuleLoader\waitForModule(), and Nssm\writeLogError().
|
static |
Flushes the log buffer to disk using async writes when available. Groups entries by file to minimise file operations. Uses async logging to avoid blocking the main process on I/O. Falls back to synchronous writes or error_log() if needed.
Definition at line 228 of file class.log.php.
References $bearsamppConfig, $bearsamppCore, APP_TITLE, queueAsyncWrite(), Config\VERBOSE_DEBUG, and Config\VERBOSE_TRACE.
Referenced by write().
|
static |
Process all queued log entries immediately (public method for manual flushing). Useful for live log monitoring or ensuring logs are written before critical operations.
Can be called at any time to flush pending async log writes.
Definition at line 347 of file class.log.php.
References processAsyncQueue().
|
static |
Get the async queue directory path.
Definition at line 515 of file class.log.php.
|
static |
Get current async queue size.
Definition at line 525 of file class.log.php.
|
static |
Returns the current log buffer size.
Definition at line 563 of file class.log.php.
|
static |
Returns the current log buffer statistics.
Definition at line 540 of file class.log.php.
|
static |
Logs an INFO-level message.
| mixed | $data | |
| string | null | $file |
Definition at line 627 of file class.log.php.
References write().
Referenced by ActionQuit\__construct(), ActionStartup\__construct(), ActionQuit\checkForOrphanedProcesses(), ActionQuit\cleanupTemporaryFiles(), Cache\clear(), ActionStartup\createSslCrts(), OpenSsl\ensureRootCaExists(), OpenSsl\ensureSslDirExists(), Batch\exitApp(), Util\getFilesToScan(), Util\installService(), ActionStartup\installServicesSequential(), OpenSsl\makeRootCa(), ActionQuit\performQuickCleanupVerification(), ActionQuit\processWindow(), OpenSsl\rebuildAllCerts(), AppPhpmyadmin\reload(), AppPhppgadmin\reload(), Apps\reload(), BinApache\reload(), BinMailpit\reload(), BinMariadb\reload(), BinMemcached\reload(), BinMysql\reload(), BinNodejs\reload(), BinPhp\reload(), BinPostgresql\reload(), Bins\reload(), BinXlight\reload(), ToolBruno\reload(), ToolComposer\reload(), ToolGhostscript\reload(), ToolGit\reload(), ToolNgrok\reload(), ToolPerl\reload(), ToolPowerShell\reload(), ToolPython\reload(), ToolRuby\reload(), OpenSsl\removeCrt(), Util\removeService(), BinApache\setEnable(), BinMailpit\setEnable(), BinMariadb\setEnable(), BinMemcached\setEnable(), BinMysql\setEnable(), BinNodejs\setEnable(), BinPhp\setEnable(), BinPostgresql\setEnable(), BinXlight\setEnable(), Win32Service\start(), ServiceHelper\startAllServicesParallel(), ServiceHelper\stopAllServicesParallel(), Apps\update(), Bins\update(), Tools\update(), QuickPick\updateModuleConfig(), ActionQuit\verifyServicesStoppedAndCleanup(), ActionQuit\verifySymlinksRemoved(), and Nssm\writeLogInfo().
|
static |
Registers the shutdown flush handler and initializes async logging. Call once during bootstrap after globals are initialised.
Automatically disables async logging when TRACE verbosity is enabled, to ensure live log monitoring shows logs immediately.
Definition at line 72 of file class.log.php.
References checkVerbosityAndAdjustAsync(), and initializeAsyncQueue().
Referenced by Root\register(), and write().
|
static |
Logs the initialisation of a class instance at TRACE level.
| object | $classInstance |
Definition at line 660 of file class.log.php.
References trace().
Referenced by AppPhpmyadmin\__construct(), AppPhppgadmin\__construct(), BinApache\__construct(), BinMailpit\__construct(), BinMariadb\__construct(), BinMemcached\__construct(), BinMysql\__construct(), BinNodejs\__construct(), BinPhp\__construct(), BinPostgresql\__construct(), Bins\__construct(), BinXlight\__construct(), Homepage\__construct(), Nssm\__construct(), Registry\__construct(), Splash\__construct(), ToolBruno\__construct(), ToolComposer\__construct(), ToolGhostscript\__construct(), ToolGit\__construct(), ToolNgrok\__construct(), ToolPerl\__construct(), ToolPowerShell\__construct(), ToolPython\__construct(), ToolRuby\__construct(), Win32Service\__construct(), and WinBinder\__construct().
|
staticprivate |
Initialize async queue directory.
Definition at line 127 of file class.log.php.
References Path\getTmpPath().
Referenced by init().
|
static |
Check if async logging is enabled.
Definition at line 505 of file class.log.php.
|
static |
Process all queued log entries at shutdown. Ensures any remaining queued logs are written before exit.
Definition at line 358 of file class.log.php.
References cleanupStaleAsyncQueue().
Referenced by flushAsyncQueue().
|
staticprivate |
Queue a log entry for asynchronous writing. Returns immediately without blocking on I/O.
| string | $file | Target log file path |
| string | $content | Log content to write |
Definition at line 311 of file class.log.php.
Referenced by flush().
|
static |
Logs the reloading of a class instance at TRACE level.
| object | $classInstance |
Definition at line 670 of file class.log.php.
References trace().
Referenced by AppPhpmyadmin\reload(), AppPhppgadmin\reload(), BinApache\reload(), BinMailpit\reload(), BinMariadb\reload(), BinMemcached\reload(), BinMysql\reload(), BinNodejs\reload(), BinPhp\reload(), BinPostgresql\reload(), BinXlight\reload(), ToolBruno\reload(), ToolComposer\reload(), ToolGhostscript\reload(), ToolGit\reload(), ToolNgrok\reload(), ToolPerl\reload(), ToolPowerShell\reload(), ToolPython\reload(), and ToolRuby\reload().
|
static |
Clears the buffer and resets statistics. Useful in tests or when re-initialising the application.
Definition at line 477 of file class.log.php.
|
static |
Appends a separator line to each log file that does not already end with one.
@global object $bearsamppRoot
Definition at line 573 of file class.log.php.
References $bearsamppRoot, Path\getBatchLogFilePath(), Path\getErrorLogFilePath(), Path\getLogFilePath(), Path\getRegistryLogFilePath(), Path\getServicesLogFilePath(), Path\getStartupLogFilePath(), and Path\getWinbinderLogFilePath().
Referenced by Root\register().
|
static |
Enable or disable async logging.
| bool | $enabled |
Definition at line 495 of file class.log.php.
|
static |
Sets the log buffer size.
| int | $size | New buffer size (1–1000). |
Definition at line 551 of file class.log.php.
|
static |
Logs a TRACE-level message.
| mixed | $data | |
| string | null | $file |
Definition at line 605 of file class.log.php.
References write().
Referenced by ActionExec\__construct(), ActionLoading\__construct(), ActionManualRestart\__construct(), ActionRebuildini\__construct(), Win32Service\callWin32Service(), BinMysql\changeRootPassword(), ActionLoading\checkAllServicesStarted(), ActionStartup\checkApacheServiceWithTimeout(), ActionStartup\checkMySQLServiceWithTimeout(), BinMysql\checkPort(), BinMysql\checkRootPassword(), Win32Service\create(), OpenSsl\createCrt(), ActionStartup\createSslCrts(), Win32Service\delete(), Symlinks\deleteCurrentSymlinks(), Win32Service\ensureReset(), Win32Service\fastServiceCheck(), ServiceHelper\forceKillService(), HttpClient\getCurlHttpHeaders(), Util\getCurlHttpHeaders(), Win32Service\getServices(), Win32Service\infos(), initClass(), BinMariadb\initData(), BinMysql\initData(), ActionStartup\installServices(), ActionStartup\installServicesSequential(), OpenSsl\isExpired(), Win32Service\isInstalled(), Win32Service\isPaused(), Win32Service\isPending(), Win32Service\isRunning(), Win32Service\isStopped(), ActionStartup\prepareService(), ActionLoading\processLoading(), ActionQuit\processWindow(), ActionStartup\processWindow(), ActionSwitchVersion\processWindow(), BinMailpit\rebuildConf(), BinApache\refreshAlias(), BinApache\refreshConf(), BinApache\refreshVhosts(), reloadClass(), Config\replaceAll(), Util\replaceInFile(), ActionStartup\rotationLogs(), Symlinks\safeRemoveSymlink(), ActionStartup\scanFolders(), BinMailpit\setVersion(), BinPhp\setVersion(), ServiceHelper\shutdownServicesParallel(), ServiceHelper\shutdownServicesSequential(), ServiceHelper\startAllServicesParallel(), Util\startLoading(), ServiceHelper\startServicesParallel(), ServiceHelper\startServicesSequential(), Win32Service\status(), Win32Service\stop(), ServiceHelper\stopAllServicesParallel(), ActionQuit\terminatePhpProcesses(), TplAppReload\triggerReload(), Core\unzipFile(), BinPhp\updateConfig(), ActionSwitchVersion\updateConfigVersion(), and Win32Service\waitForServiceDeletion().
|
static |
Logs a WARNING-level message.
| mixed | $data | |
| string | null | $file |
Definition at line 638 of file class.log.php.
References write().
Referenced by ActionQuit\checkForOrphanedProcesses(), ActionQuit\cleanupTemporaryFiles(), Symlinks\createModuleSymlink(), OpenSsl\ensureSslDirExists(), Cache\get(), CacheManager\init(), FiberModuleLoader\init(), Batch\initializeMariadb(), Batch\initializeMysql(), Batch\initializePostgresql(), Util\installService(), ActionStartup\installServicesSequential(), OpenSsl\isExpired(), ActionQuit\performQuickCleanupVerification(), ActionQuit\processWindow(), QuickPick\regenerateMenuSafe(), ToolGit\reload(), OpenSsl\removeCrt(), Util\removeService(), Symlinks\safeRemoveSymlink(), UtilInput\sanitizePath(), UtilInput\sanitizePID(), UtilInput\sanitizePort(), UtilInput\sanitizeServiceName(), Csrf\validateRequest(), Csrf\validateToken(), ActionQuit\verifyServicesStoppedAndCleanup(), ActionQuit\verifySymlinksRemoved(), FiberModule\wait(), FiberModuleLoader\waitAll(), and CacheManager\writeCache().
|
staticprivate |
Writes a message to a log file, using the buffer to reduce I/O.
The file path is resolved as follows:
| mixed | $data | The message to log. |
| string | $type | One of the Log level constants. |
| string | null | $file | Explicit file path, or null to use the default. |
Definition at line 154 of file class.log.php.
References $bearsamppConfig, $bearsamppCore, $bearsamppRoot, flush(), Path\getErrorLogFilePath(), Path\getHomepageLogFilePath(), Path\getLogFilePath(), init(), Config\VERBOSE_DEBUG, Config\VERBOSE_REPORT, Config\VERBOSE_SIMPLE, and Config\VERBOSE_TRACE.
Referenced by debug(), error(), info(), trace(), and warning().
|
staticprivate |
Definition at line 58 of file class.log.php.
|
staticprivate |
Definition at line 55 of file class.log.php.
|
staticprivate |
Definition at line 38 of file class.log.php.
|
staticprivate |
Definition at line 41 of file class.log.php.
|
staticprivate |
Definition at line 47 of file class.log.php.
|
staticprivate |
Definition at line 61 of file class.log.php.
|
staticprivate |
Definition at line 44 of file class.log.php.
| const DEBUG = 'DEBUG' |
Definition at line 34 of file class.log.php.
| const ERROR = 'ERROR' |
Definition at line 31 of file class.log.php.
| const INFO = 'INFO' |
Definition at line 33 of file class.log.php.
| const TRACE = 'TRACE' |
Definition at line 35 of file class.log.php.
| const WARNING = 'WARNING' |
Definition at line 32 of file class.log.php.