Log weather changes #897

Closed
opened 2020-12-07 04:35:01 +01:00 by kneekoo · 7 comments
Contributor

Is it possible to log weather changes? They're rare anyway, so it wouldn't hurt to have them. It would improve debugging odd cases, like the one I mentioned in #896.

Examples:
date + time [EVENT] Server: Weather changed from clear to thunder
date + time [EVENT] Server: Weather changed from thunder to snow
date + time [EVENT] Server: Weather changed from snow to clear
date + time [EVENT] Server: Weather changed from clear to rain
date + time [EVENT] Server: Weather changed from rain to clear

I specifically added both states in a single line, because it's a short text anyway, and it saves you time from searching the previous change event.

Is it possible to log weather changes? They're rare anyway, so it wouldn't hurt to have them. It would improve debugging odd cases, like the one I mentioned in #896. Examples: date + time [EVENT] Server: Weather changed from clear to thunder date + time [EVENT] Server: Weather changed from thunder to snow date + time [EVENT] Server: Weather changed from snow to clear date + time [EVENT] Server: Weather changed from clear to rain date + time [EVENT] Server: Weather changed from rain to clear I specifically added both states in a single line, because it's a short text anyway, and it saves you time from searching the previous change event.
Wuzzy added the
documentation
label 2020-12-08 01:11:47 +01:00
LizzyFleckenstein03 added this to the 0.71.0 milestone 2021-01-27 08:17:12 +01:00
Contributor

@kneekoo This is implemented already. Can you please check?

If debug_log_level is set to verbose, you get the messages like that:

[mcl_weather] Weather data saved: state=[STATE] end_time=[END_TIME]

Changing level to action now

@kneekoo This is implemented already. Can you please check? If debug_log_level is set to verbose, you get the messages like that: ```[mcl_weather] Weather data saved: state=[STATE] end_time=[END_TIME]``` Changing level to action now
Author
Contributor

That's something else - it saves the state of the weather on server shutdown. What I asked was if it's possible to log the weather changes, for a better context surrounding certain events.

Now thanks to the commit mentioned here I noticed that it's possible to log it from this block (in the mclweather.setrandomweather function implementation):

if new_weather then
        mcl_weather.change_weather(new_weather)			
end

This would probably work:

if new_weather then
        mcl_weather.change_weather(new_weather)			
        minetest.log("action", "[mcl_weather] Weather changed from "..weather_name.." to "..new_weather)
end
That's something else - it saves the state of the weather on server shutdown. What I asked was if it's possible to log the weather changes, for a better context surrounding certain events. Now thanks to the commit mentioned here I noticed that it's possible to log it from this block *(in the mclweather.setrandomweather function implementation)*: ``` if new_weather then mcl_weather.change_weather(new_weather) end ``` This would probably work: ``` if new_weather then mcl_weather.change_weather(new_weather) minetest.log("action", "[mcl_weather] Weather changed from "..weather_name.." to "..new_weather) end ```
Contributor

If I understand correctly, it saves the whether not only on shutdowns but on any change, that's why I thought it's what you want. Sorry if I'm wrong. Let's check it :)

If I understand correctly, it saves the whether not only on shutdowns but on any change, that's why I thought it's what you want. Sorry if I'm wrong. Let's check it :)
Author
Contributor

To manually change the weather via chat, I did this and it works:

    local current_weather = mcl_weather.state
    local success = mcl_weather.change_weather(new_weather, end_time)
    if success then
      minetest.log("action", "[mcl_weather] Weather changed manually from "..current_weather.." to "..new_weather)
      return true

I don't know how to specify who changed the weather, but this would be nicer:

player_name changed the weather from X to Y

Indeed, save_weather() is called in mcl_weather.change_weather, so I guess it should log it. It's just that it won't have the before/after format I mentioned.

P.S. Finally, the weather changed on its own and the other line of code did its job as expected. Again, my whole point was to log both weather states in a single line.

To manually change the weather via chat, I did this and it works: ``` local current_weather = mcl_weather.state local success = mcl_weather.change_weather(new_weather, end_time) if success then minetest.log("action", "[mcl_weather] Weather changed manually from "..current_weather.." to "..new_weather) return true ``` I don't know how to specify who changed the weather, but this would be nicer: > player_name changed the weather from X to Y Indeed, save_weather() is called in `mcl_weather.change_weather`, so I guess it should log it. It's just that it won't have the before/after format I mentioned. P.S. Finally, the weather changed on its own and the other line of code did its job as expected. Again, my whole point was to log both weather states in a single line.
Contributor

Okay, made the single lines... quite fun for me:

2021-01-28 11:37:24: ACTION[Main]: [mcl_weather] load_weather changed the weather from none to none
2021-01-28 11:43:36: ACTION[Main]: [mcl_weather] load_weather changed the weather from none to none
2021-01-28 11:44:09: ACTION[Server]: [mcl_weather] singleplayer changed the weather from none to none
2021-01-28 11:44:26: ACTION[Server]: [mcl_weather] singleplayer changed the weather from none to thunder
2021-01-28 11:44:49: ACTION[Server]: [mcl_weather] sleep changed the weather from thunder to none
Okay, made the single lines... quite fun for me: ``` 2021-01-28 11:37:24: ACTION[Main]: [mcl_weather] load_weather changed the weather from none to none 2021-01-28 11:43:36: ACTION[Main]: [mcl_weather] load_weather changed the weather from none to none 2021-01-28 11:44:09: ACTION[Server]: [mcl_weather] singleplayer changed the weather from none to none 2021-01-28 11:44:26: ACTION[Server]: [mcl_weather] singleplayer changed the weather from none to thunder 2021-01-28 11:44:49: ACTION[Server]: [mcl_weather] sleep changed the weather from thunder to none ```

Why don't you make it say "clear" instead of "none"?

Why don't you make it say "clear" instead of "none"?
Contributor

Clear would be fine, really, feel free to fixreplaced

Clear would be fine, really, ~~feel free to fix~~**replaced**
kay27 closed this issue 2021-01-28 14:56:07 +01:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: VoxeLibre/VoxeLibre#897
No description provided.