Creating Logs page

Asked

Viewed 459 times

1

I created a table in my database usr_logs with the following columns:

  • id
  • email
  • ip
  • team
  • date
  • sucess

These records alone are sufficient, or I need to add something else?

How do I display all the data entered in this table?

  • 2

    If you can explain better the problem you have in particular and, if possible, show code you have done where this problem is. Your question is too broad, see Help Center How To Ask..

  • You want the table user_logs What for? Logins? or Error logging?

  • @Paulo Pimentel this is login or log??? "logs" are different from "logins"

  • They are logs, records of users of my system, I want to create the logs page, where I will follow the logs by the page and not by SQL, where only I will have access to this page, understood?

2 answers

3

The fields you will put is optional and depends on what exactly you want to store, but I believe the main one is missing to inform what happened (a message in the log to identify what that record is about, because at the moment you only identify that something happened). Depending on the type of log you could have an extra field to know which type of log (WARNING, ERROR, NOTICE or others you come to assign), if you think it necessary you can still put the name of the class, method name or function, file name and row number this would help at debug time and you can release different views of this table using view, so it would be possible for you to have a complete table to debug and show a simpler one so someone could just follow up on what happened and whether they had an error or not, it could even add the user who was using the application when the error occurred, version of the code. To display the entered data it is simple to just connect to the database and extract the data on screen. I strongly advise the use of jQuery.Datatables by the ease of implementation, documentation and functionality, if it is to display this data on the Web, if it is desktop application you can use a Data Grid present in the programming language.

In this link you will find a complete example of implementing datatable with php the use is quite simple to use you will need the plugin of datatable and jquery, if you wish you can still apply the boostraps on it. There are other ways this is just one of them.

Some fields that can be added (all this is optional and goes from the need of each)

  • classname
  • methodname
  • functionname
  • line
  • filename
  • message
  • review
  • user_id
  • type
  • Okay buddy, I’ll give you a study and give you a feedback here,.

1

Although @Sileno Brito’s response is pretty cool, I’m a fan of the Monolog where you can inform email, ip, sucess as part of context and the datetime is already generated by the same component, and then store the output in the format you think best.

At each Log recording, you will inform the log type (WARNING, ERROR, NOTICE ...)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.