GitXplorerGitXplorer
j

kirbylog

public
23 stars
1 forks
0 issues

Commits

List of commits on branch main.
Unverified
acb7cf83c9851e28d44d49e5cc8e9b3848a8664f

chore: release v1.4.7

jjohannschopplich committed a year ago
Unverified
8fbe0753f7756fe0dae2d23b9769a066b825ce52

refactor: remove global `kirby()` usage

jjohannschopplich committed a year ago
Unverified
8c5e7b80534ba1a4530783673fdbd709661c333b

chore: update og image

jjohannschopplich committed a year ago
Unverified
e23d4e28e917df3d070a79cbbb6599fbfc2b7833

chore: add og image

jjohannschopplich committed a year ago
Unverified
0f598b4baad4f2f42463418dc63eed7691326c23

chore: add og image

jjohannschopplich committed a year ago
Unverified
bb86bfb1ba6b528a9b228c65d9d94011e484e7dc

chore: add og image

jjohannschopplich committed a year ago

README

The README file for this repository.

Kirbylog

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/2023-08-23.log:

[2023-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

Composer

composer require johannschopplich/kirbylog

Download

Download and copy this repository to /site/plugins/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:

[2023-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 date('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 License © 2022-PRESENT Johann Schopplich