Git Product home page Git Product logo

Comments (7)

lorenzo avatar lorenzo commented on May 24, 2024

Can you figure out what version of elastic it is using?

from audit-stash.

lorenzo avatar lorenzo commented on May 24, 2024

Elastica

from audit-stash.

LDSign avatar LDSign commented on May 24, 2024

Yes, of course ;)

https://github.com/ruflin/Elastica/releases/tag/2.3.1

Installed via composer dependency.

from audit-stash.

LDSign avatar LDSign commented on May 24, 2024

Hi

Ive just switched to my own persister.

Could you have a quick look if its a good practice to split the meta data into individual fields and jsonify the original and changed data?

namespace App\Persister;

use AuditStash\PersisterInterface;
use Cake\ORM\Entity;
use Cake\ORM\TableRegistry;

class DatabasePersister implements PersisterInterface
{
    public function logEvents(array $auditLogs)
    {
        //pr($auditLogs);
        //die();
        foreach ($auditLogs as $log) {
            $eventType = $log->getEventType();
            $data = [
                'timestamp' => $log->getTimestamp(),
                'transaction' => $log->getTransactionId(),
                'type' => $log->getEventType(),
                'primary_key' => $log->getId(),
                'source' => $log->getSourceName(),
                'parent_source' => $log->getParentSourceName(),
                'original' => ($eventType === 'create' || $eventType === 'delete') ? null : json_encode($log->getOriginal()),
                'changed' => $eventType === 'delete' ? null : json_encode($log->getChanged()),
                'ip' => $log->getMetaInfo()['ip'],
                'url' => $log->getMetaInfo()['url'],
                'user_id' => $log->getMetaInfo()['user'],
            ];

            TableRegistry::get('Audits')->save(new Entity($data));
        }
    }
}

And Ive had no luck to populate get the orignal data at the delete event. I think it makes sense to log the original data here. Any idea how to get this in the method above?

Thanks,
Frank

from audit-stash.

lorenzo avatar lorenzo commented on May 24, 2024

@LDSign The error seems to come from the library, not the plugin.. which is odd. It is not a bad idea to do what you are doing. I originally stored the fields in Mysql, but became very slow, consumed a lot of space and could not search freely on the fields. If you only want to store, then that is entirely fine

from audit-stash.

angelxmoreno avatar angelxmoreno commented on May 24, 2024

I had the same errors but using the built-in elastic search Persister. I was using ElasticSearch 5.5. I downgraded to 2.4.6 and it works. Looks like the issue is an incompatibility at the ruflin/Elastica level. Thank you for the plugin @lorenzo

from audit-stash.

danfournier avatar danfournier commented on May 24, 2024

@LDSign $log->getMetaInfo() returns null in my case. Any idea why? The rest works fine per your example.

from audit-stash.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.