Logs which process created or modified a record

Overview

Laravel Process Stamps

Latest Version on Packagist Build Status Total Downloads

It is sometimes very useful to know which process created or modified a particular record in your database. This package provides a trait to add to your Laravel models which automatically logs that for you.

Installation

You can install the package via composer:

composer require orisintel/laravel-process-stamps

Configuration

php artisan vendor:publish --provider="\OrisIntel\ProcessStamps\ProcessStampsServiceProvider"

Running the above command will publish both the migration and the config file.

Usage

After adding the proper fields to your table, add the trait to your model.

// User model
class User extends Model
{
    use ProcessStampable;

Next, create a migration for your table and include the following:

$table->processIds();

To specify your own foreign key or index names, include the following options:

$table->processIds([
    'created_index_name' => 'custom_created_index_name',
    'updated_index_name' => 'custom_updated_index_name',
    'created_foreign_key_name' => 'custom_created_foreign_key_name',
    'updated_foreign_key_name' => 'custom_updated_foreign_key_name',
    ]);

That will generate the nessesary field names to track processes.

Testing

composer test

Using Docker

All assets are set up under the docker-compose.yml file. The first time you run the docker image you must build it with the following command:

docker-compose build

Then you can bring it up in the background using:

docker-compose up -d

And the image is aliased so you can access its command line via:

docker exec -it processes-stamp-app /bin/bash

From there you can run the tests within an isolated environment

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Comments
  • Revert back to cache lock w/ firstOrCreate

    Revert back to cache lock w/ firstOrCreate

    While in a transaction upsert will lock the row until the transaction is finished. Using a cache lock avoids this but also introduces a possible duplicate exception in rare cases.

    Test cases for both the transaction lock and duplicate exceptions will follow in the future but for now this is the best case scenario

    opened by solflare 0
  • configurable parent resolve

    configurable parent resolve

    This allows you to turn off the ability to recursively resolve parent ids in the process stamps. This can lessen the load on the package / db and also avoid some race conditions.

    opened by tomschlick 0
  • Parent / child process ids

    Parent / child process ids

    Creates the ability to have parent / child process ids.

    Example: The parent of php artisan post:refresh --post-id=134 would be php artisan post:refresh. This allows you to correlate multiple items with similar base commands (but different params) together.

    enhancement 
    opened by tomschlick 0
  • Updated stamp creation to leverage the retry helper method

    Updated stamp creation to leverage the retry helper method

    Issue

    When multiple requests happen (AJAX Async processing) and they will all have the same process hash the first request will work, some subset of following requests will fail, then the rest will work. This happens because if the hash doesn't already exist we block via a cache lock. This then returns a null instance for the subsequent requests until the record is created.

    Solution

    Updated the firstOrCreate method to use the retry helper. Now when a null instance would be returned instead we'll throw an exception and retry both finding the instances in the DB and checking on the Cache::lock.

    I tried to set sane starting values (25ms sleep and 4 total retries) which should be well enough for most instances to create a single DB records (100ms total)

    Release notes

    Better handling of stamp creation to support high concurrency

    opened by qschmick 4
  • Migration excluded from Migrate:fresh

    Migration excluded from Migrate:fresh

    Running php artisan migrate:fresh seems to exclude the process stamps, requiring separately running php artisan migrate to get that into the DB structure. As a result the stamps migration ends up last in the migrations table. That complicates use of the migration/schema snapshot-ing as the second to last migration is always shifting.

    opened by paulrrogers 0
Releases(v3.4.0)
Owner
ORIS Intelligence
Online price monitoring & enforcement tools.
ORIS Intelligence
Small laravel package for viewing api logs which can be used in debugging.

This is a small package that can helps in debugging api logs. It can log request method, url, duration, request payload, which models are retrieved, controller and method.

awt 334 Jan 6, 2023
Open source medical record system on CakePHP (OMCAKE)

omcake v0.1 小さな診療所用の電子カルテ(もどき)です。 奥村晴彦先生のtwitter オープンソースの電子カルテシステムで、WebベースでクライアントOSを選ばず、 サーバは普通のLinuxで動くPHPとか、ないんだろうか。 で唐突に召喚され、それ、ウチにありますけど〜、とノコノコ出てき

古林 敬一 7 Aug 16, 2022
Sends your logs to files, sockets, inboxes, databases and various web services

Monolog - Logging for PHP Monolog sends your logs to files, sockets, inboxes, databases and various web services. See the complete list of handlers be

Jordi Boggiano 20.1k Jan 8, 2023
Amazon Web Services CloudWatch Logs Handler for Monolog library

AWS CloudWatch Logs Handler for Monolog Handler for PHP logging library Monolog for sending log entries to AWS CloudWatch Logs service. Before using t

Maksym Leonov 377 Dec 16, 2022
Paste, share and analyse Minecraft server logs

mclo.gs Paste, share & analyse your Minecraft server logs About The project mclo.gs was created in 2017 by the Aternos team after more than 4 years of

Aternos 99 Jan 3, 2023
Keep your laravel logs small and tidy.

Logs can get quite out of hand. This package helps save server space and keep your Laravel log files small.

Accent Interactive 73 Nov 14, 2022
Capture and monitor detailed error logs with nice dashboard and UI

Capture and monitor detailed error logs with nice dashboard and UI Requirements Check Laravel 6 requirements Check Laravel 7 requirements Installation

Bugphix 107 Dec 12, 2022
Small package that can helps in debugging with API logs for Laravel Project.

Rest APIs Logger This is a small package that can helps in debugging with API logs. Installation Install the package via composer composer require tfs

Sunny Mahajan 7 Aug 31, 2022
Clear all your logs in [linux/windows] servers 🛡️

Log-killer Log Killer is tool for [Linux/Windows] Servers This tool will delete all your logs just download the tool and run it on the server if your

Rizer 281 Nov 24, 2022
Small tool that extracts witness data from Helium miner logs.

Helium Miner Logs Analyzer Small tool that extracts witness data from Helium miner logs. It currently works for the Pisces 100 and miner version miner

Iñigo Flores 42 Dec 11, 2022
Sends your logs to files, sockets, inboxes, databases and various web services

Monolog - Logging for PHP ⚠ This is the documentation for Monolog 3.x, if you are using older releases see the documentation for Monolog 2.x or Monolo

Jordi Boggiano 20.1k Jan 7, 2023
Allows the date format for "created", "modified" and "published" columns to be set within a Lister.

Lister Native Date Format Allows the date format for "created", "modified" and "published" columns to be set within a Lister or Lister Pro instance. W

Robin Sallis 1 Jan 13, 2022
Record created by, updated by and deleted by on Eloquent models automatically.

quarks/laravel-auditors Record created by, updated by and deleted by (if SoftDeletes added) on Eloquent models automatically. Installation composer re

Quarks 3 Jun 13, 2022
A modified version of the Laravel Framework

Hexavel Framework Hexavel is a restructured version of Laravel, with the purpose of providing better work flows which will simplify the development pr

Peter Fox 7 Nov 1, 2022
Allows you to process logs using any PSR-3 compatible logger such as Monolog

Yii 2 PSR Log Target Allows you to process logs using any PSR-3 compatible logger such as Monolog

Alexander Makarov 67 Dec 14, 2022
QPM, the process management framework in PHP, the efficient toolkit for CLI development. QPM provides basic daemon functions and supervision mechanisms to simplify multi-process app dev.

QPM QPM全名是 Quick(or Q's) Process Management Framework for PHP. PHP 是强大的web开发语言,以至于大家常常忘记PHP 可以用来开发健壮的命令行(CLI)程序以至于daemon程序。 而编写daemon程序免不了与各种进程管理打交道。Q

Comos 75 Dec 21, 2021
Process - The Process component executes commands in sub-processes.

Process Component The Process component executes commands in sub-processes. Sponsor The Process component for Symfony 5.4/6.0 is backed by SensioLabs.

Symfony 7.1k Dec 29, 2022
Small laravel package for viewing api logs which can be used in debugging.

This is a small package that can helps in debugging api logs. It can log request method, url, duration, request payload, which models are retrieved, controller and method.

awt 334 Jan 6, 2023
A sampling profiler for PHP written in PHP, which reads information about running PHP VM from outside of the process.

Reli Reli is a sampling profiler (or a VM state inspector) written in PHP. It can read information about running PHP script from outside of the proces

null 272 Dec 22, 2022