“This is the 18th day of my participation in the Gwen Challenge in November. Check out the details: The Last Gwen Challenge in 2021”
Be sensitive to data, develop the habit of log statistical analysis, and be responsible for data in project promotion.
Importance of log statistical analysis
Today, I received a request that asked me to count the number of avatar changes of approved users to evaluate the workload of the review.
Instead of taking action immediately after receiving the requirements, I decide whether to log statistics or keep them in DB. Because only query data to evaluate workload, there is no need to save to DB.
So I’m going to save it in Log, and I’m going to roll the code…
Something to be proud of happened. I found out I had logged before.
Before, when no one asked for it, I thought it might be useful when I got here, so I logged it. (I forgot about it myself and found it when I looked it up in the code.)
So I made statistical analysis of the Log data and soon gave the data to the operation students to evaluate the workload.
As an aside: if I hadn’t logged in ahead of time, the operations students would have had to wait a week to get the data if they needed to evaluate in the surrounding time range.
Because I logged in advance and recorded the data, I exported the data of the last two months, which greatly saved the time cost.
Here are some tips for using Laravel logs
I’m not going to cover basic uses, there are so many of them, but just some of the more elegant uses that I think the average person might not know about.
Logging parameters
We can use the Log::info() or the shorter info() extra parameter information to record more detailed information
Log::info('User failed to login.', ['id' => $user->id]);
Copy the code
More convenient DD
Instead of using DD ($result), we can add ->dd() to the end of the Eloquent sentence or any collection.
/ / $users = User: before: the where (' name ', 'Taylor) - > get (); dd($users); / / $users = User: now: the where (' name ', 'Taylor) - > get () - > dd ();Copy the code
Proper integration of three-party tools
We can try to use tripartite statistical tools to aggregate queries and visual analysis of logs.
For example, we used aliyun’s log service
Using Superset, a lightweight BI tool, set up the data visualization background. Superset provides a variety of predefined visualizations for most data presentation functions.
Through the reasonable integration of three-party tools can greatly improve our development speed and project efficiency.
Last but not least
Technical group please come here. Or add my wechat account wangzhongyang0601 to learn and make progress together.
Thank you for your likes, comments and attention. Thank you for your support and thanks to ღ(´ · ᴗ · ‘)