🪃 Zero-dependency global `kirbylog()` helper for any content

Overview

Kirbylog

The most simple, Kirby-esque way to log content to file.

Most of the time, I just want to log some string or array to a file. That's what this plugin does. The given input:

// Anywhere in your code
kirbylog('Something happened');

… will produce this example output site/logs/2021-08-23.log:

[2021-08-23 09:28:04] INFO Something happened

Key features

  • 🪃 Global kirbylog() helper usable anywhere
  • 💬 Arrays will be converted to JSON
  • 🧩 Dependency-free, based solely on Kirby internals
  • 🔢 Supports logging levels

Installation

Download

Download and copy this repository to /site/plugins/kirbylog.

Git submodule

git submodule add https://github.com/johannschopplich/kirbylog.git site/plugins/kirbylog

Composer

composer require johannschopplich/kirbylog

Usage

This plugin registers a global kirbylog function, callable anywhere.

kirbylog('Log this to file');

Logging level

Pass the logging level of your choice as the second parameter (upper or lower case is irrelevant). By default, content will be logged with the INFO level. This plugin uses logging levels described by RFC 5424. Of course, you can tailor them to your needs.

kirbylog($response->code(), 'error');

Generated log file:

[2021-08-23 12:43:56] ERROR 401

Options

All options have to prefixed with johannschopplich.kirbylog. in your config.php.

Option Default Type Description
dir fn () => kirby()->root('logs') string or function Root directory for your logs. Note: Wrap kirby() calls in a function, because Kirby hasn't initialized in config.php yet.
filename strftime('%Y-%m-%d') . '.log' string Filename to write logged content to.
defaultLevel info string Default logging level to use. Doesn't need to be case sensitive.
levels Source reference array List of logging levels. By default, kirbylog supports the logging levels described by RFC 5424.

Configuration example for your site/config/config.php file:

return [
    'johannschopplich' => [
        'kirbylog' => [
            'filename' => 'test.log'
        ]
    ]
]

Alternatives

License

MIT

You might also like...
Library for check dependency between modules inside projects

PHP Dependency analyzer PHP DA is tool for check and support dependencies inside your project clear. For example: You have project with 3 root namespa

A PHP dependency vulnerabilities scanner based on the Security Advisories Database.

Enlightn Security Checker The Enlightn Security Checker is a command line tool that checks if your application uses dependencies with known security v

An installer package that let's you install NodeJS and NPM as a Composer dependency.

NodeJS installer for Composer This is an installer that will download NodeJS and NPM and install them in your Composer dependencies. Installation is s

Dependency graph visualization for composer.json (PHP + Composer)
Dependency graph visualization for composer.json (PHP + Composer)

clue/graph-composer Graph visualization for your project's composer.json and its dependencies: Table of contents Usage graph-composer show graph-compo

A small CLI tool to check missing dependency declarations in the composer.json and module.xml

Integrity checker Package allows to run static analysis on Magento 2 Module Packages to provide an integrity check of package. Supported tools: Compos

Simple, single-file and dependency-free AWS S3 client.

Simple, single-file and dependency-free AWS S3 client. Why? In some scenarios we want the simplest and lightest S3 client possible. For example in Bre

:passport_control: Helper for Google's new noCAPTCHA (reCAPTCHA v2 & v3)
:passport_control: Helper for Google's new noCAPTCHA (reCAPTCHA v2 & v3)

noCAPTCHA (new reCAPTCHA) By ARCANEDEV© What is reCAPTCHA? reCAPTCHA is a free service that protects your site from spam and abuse. It uses advanced r

A simple helper to generate and display pagination navigation links

Intro to CHocoCode Paginator Friendly PHP paginator to paginate everything This package introduces a different way of pagination handling. You can rea

Helper to automatically load various Kirby extensions in a plugin

Autoloader for Kirby Helper to automatically load various Kirby extensions in a plugin Commerical Usage This package is free but if you use it in a co

Comments
  • `strftime` is deprecated as of PHP 8.1

    `strftime` is deprecated as of PHP 8.1

    You can see in the PHP docs, for instance.

    Alternatives:

    • I used date() in my config
    • DateTime::format, or date_format(date_create(), "format")

    Where:

    • config
    • documentation about config options

    I can PR

    opened by adamkiss 3
Releases(v1.4.6)
Owner
Johann Schopplich
Web designer/developer. Pharmacist prior to that.
Johann Schopplich
Fixes WordPress 5.9 global CSS styles specificity issues

Fixes WordPress 5.9 global CSS styles specificity issues

Oliver Juhas 3 Feb 22, 2022
An Elasticsearch engine plugin for Moodle's Global Search

Moodle Global Search - Elasticsearch Backend This plugin allows Moodle to use Elasticsearch as the search engine for Moodle's Global Search. The follo

Catalyst IT 12 Nov 3, 2022
Packet-driven global form interaction-spam blocker for PM.

Looking for testers and README improvers! Form Interaction Fix Interaction-spam Interaction spam is often a problem for players who use the mouse as t

EndermanbugZJFC 5 Dec 16, 2022
Magento 2 Debug Helper Module for easy debugging with Xdebug and PHPStorm or any other IDE

Magento 2 Debug Helper Information and Usage Magento 2 Debug Helper Module usage with PHPStorm and Xdebug Installation To install the Magento 2 Debug

Dmitry Shkoliar 13 May 24, 2022
salah eddine bendyab 18 Aug 17, 2021
Track any ip address with IP-Tracer. IP-Tracer is developed for Linux and Termux. you can retrieve any ip address information using IP-Tracer.

IP-Tracer is used to track an ip address. IP-Tracer is developed for Termux and Linux based systems. you can easily retrieve ip address information using IP-Tracer. IP-Tracer use ip-api to track ip address.

Rajkumar Dusad 1.2k Jan 4, 2023
📦🚀 Fast, zero config application bundler with PHARs.

Fork of the unmaintained box2 project. This project needs your help! Upgrading from Box2? Checkout the upgrade guide! Goal The Box application simplif

Box Project 865 Dec 26, 2022
Tool based on deployer.org to perform zero downtime deployments of Magento 2 projects

Magento 2 Deployer Plus Reliable fully-automated deployments tool for Magento 2. Zero downtime deployments on Magento versions >= 2.2 Automating your

Juan Alonso 194 Dec 27, 2022
🧬 Nano is a zero-config, no skeleton, minimal Hyperf distribution that allows you to quickly build a Hyperf application with just a single PHP file.

Nano is a zero-config, no skeleton, minimal Hyperf distribution that allows you to quickly build a Hyperf application with just a single PHP file.

Hyperf 273 Jan 4, 2023
Detect flaws in your architecture, before they drag you down into the depths of dependency hell ...

Detect flaws in your architecture before they drag you down into the depths of dependency hell ... What it does System Requirements Installation Phive

Michael Haeuslmann 507 Dec 27, 2022