golangorg/logkit

Versions of this package have been flagged as malware by Aikido!

Logging functions, also handles CLI output

Maintainers

Package info

github.com/golangorg/logkit

pkg:composer/golangorg/logkit

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.3 2026-04-06 23:57 UTC

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 to false, 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's date() function.

Log Levels

  • LOG_ERROR
  • LOG_WARN
  • LOG_NOTICE
  • LOG_INFO
  • LOG_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 null when 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.