golangorg / logkit
Versions of this package have been flagged as malware by Aikido!
Logging functions, also handles CLI output
v1.0.3
2026-04-06 23:57 UTC
Requires
- php: >=5.3.2
- openlss/lib-config: dev-master
Requires (Dev)
- openlss/core-boot: dev-master
This package is not auto-updated.
Last update: 2026-04-07 15:50:46 UTC
README
Lightweight PHP logging helpers with optional CLI output.
Installation
composer require golangorg/logkit
The package autoloads func/log.php and src/config.php, so the logging helpers are available after Composer autoload is loaded.
Quick Start
<?php use LSS\Config; Config::set('log', 'file', __DIR__ . '/app.log'); Config::set('log', 'level', LOG_INFO); write_log('Application started'); write_log('Something worth noting', LOG_NOTICE); write_log('Something went wrong', LOG_ERROR);
When running in CLI mode, each log line is also echoed to stdout unless you define LOG_QUIET before calling write_log().
Configuration
Default configuration:
$config['log']['level'] = LOG_INFO; $config['log']['file'] = false; $config['log']['format'] = '[%s] %s - %s'; $config['log']['date_format'] = 'm/d/Y g:i:sA';
log.level: highest log level that will be written. Messages above this level are ignored.log.file: path to the log file. If set tofalse, file logging is disabled.log.format:sprintf()format string with placeholders for log level, date, and message, in that order.log.date_format: date format passed to PHP'sdate()function.
Log Levels
LOG_ERRORLOG_WARNLOG_NOTICELOG_INFOLOG_DEBUG
API
write_log($msg, $level = LOG_INFO)
Writes a formatted log message to the configured log file.
$msg: message to write.$level: one of the log level constants listed above.- Returns the number of bytes written, or
nullwhen the message is skipped.
close_log_file()
Closes the active log file handle. In normal use this is also registered automatically on shutdown after the first write.