How to have log ?

QuestionsHow to have log ?
biowan asked 10 years ago

Hi,

Is it possible to have log of JSon operation ?

Thanks.

8 Answers
Abu Ghufran answered 10 years ago

Hello,

What exactly do you mean by JSON operations ?
Please give some examples.

Thanks

biowan answered 10 years ago

Hi,

For add/update/delete operations.

If a user has update a row, we can have for exemple in the json.log :
year.month.day hour:minute operation session_id db_name.table_name query_information

2013.12.06 12:00 update 123456 prod_db.articles update articles set color=red where id=123
2013.12.06 12:30 delete 234455 prod_db.articles delete from articles where id=789
2013.12.06 12:32 update 123456 prod_db.articles update article set price=50 where id=123

Somethings like that. Maybe it's already existed with JSON.php lib ?

Abu Ghufran answered 10 years ago

Hello,

Not sure for JSON.php as it is a failover for php build-in JSON.
If you want to log Add/Edit/Del operations, you can log them using custom events.

For e.g.

// params are array(<function-name>,<class-object> or <null-if-global-func>,<continue-default-operation>)
// if you pass last argument as true, functions will act as a data filter, and insert/update will be performed by grid
$e["on_insert"] = array("add_client", null, true);
$e["on_update"] = array("update_client", null, true);
$e["on_delete"] = array("delete_client", null, true);
$grid->set_events($e);

function update_client($data)
{
// logging code
}

and so on. Refer demos/editing/custom-events.php for code.

biowan answered 10 years ago

Ok, thanks.
I will try it next week. Tell you more.

Arne answered 10 years ago

I'm also interested in this logging.
Do you have a complete code for this?
I'm using sqlserver and want to log all these avtivities into a simple table.

I think I need a little help here…

Abu Ghufran answered 10 years ago

Logging demo is not ready yet. It would be simple if you follow demos/editing/custom-events.php

$e["on_insert"] = array("add_callback", null, true);
$e["on_update"] = array("update_callback", null, true);
$e["on_delete"] = array("delete_callback", null, true);
$grid->set_events($e);

function add_callback($data)
{
// logging code
}

function update_callback($data)
{
// logging code
}

function delete_callback($data)
{
// logging code
}

$data contains posted data, you can use print_r for further help.

Arne answered 10 years ago

I'm sorry. I'm not so good in this so I need more help.
Where should I put "$grid->set_events($e);"?
If I put in this in my code, the webpage does not output anything. Even if I don't have any code inside my new function.

And I can't find any complete example using the event function.

Abu Ghufran answered 10 years ago

Hello Arne,

Please email me your existing code at [email protected].
I'll update the code with logging events and reply you back.

Regards,

Your Answer

15 + 3 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?