mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2026-08-26 22:57:39 +01:00
[MIRROR] use ring buffer for admin logs (#12528)
Co-authored-by: Kashargul <144968721+Kashargul@users.noreply.github.com>
This commit is contained in:
co-authored by
Kashargul
parent
88084ea9e2
commit
25aa2b8650
@@ -190,7 +190,7 @@
|
||||
update_icon()
|
||||
return
|
||||
else if (!is_loosen)
|
||||
user.visible_message(span_warningplain(span_bold("\The [user]") + " tries to removes \the [tank] from \the [src] but it won't budge."), span_warning("You try to removes \the [tank] from \the [src] but it won't budge."))
|
||||
user.visible_message(span_warningplain(span_bold("\The [user]") + " tries to removes \the [tank] from \the [src] but it won't budge."), span_warning("You try to remove \the [tank] from \the [src] but it won't budge."))
|
||||
return
|
||||
if ("Toggle valve")
|
||||
if (!tank)
|
||||
|
||||
@@ -27,12 +27,15 @@
|
||||
/// IF YOU CHANGE THIS VERIFY LOGS ARE STILL PARSED CORRECTLY
|
||||
var/internal_formatting = FALSE
|
||||
|
||||
/// List of log entries for this category
|
||||
var/list/entries = list()
|
||||
/// Ring buffer of log entries for this category
|
||||
var/list/log_ring = list()
|
||||
|
||||
/// Total number of entries this round so far
|
||||
var/entry_count = 0
|
||||
|
||||
/// We have a lot more than those log lines, so we only store the last ones in a ring
|
||||
var/ring_write_index = 1
|
||||
|
||||
GENERAL_PROTECT_DATUM(/datum/log_category)
|
||||
|
||||
/// Add an entry to this category. It is very important that any data you provide doesn't hold references to anything!
|
||||
@@ -49,8 +52,14 @@ GENERAL_PROTECT_DATUM(/datum/log_category)
|
||||
|
||||
write_entry(entry)
|
||||
entry_count += 1
|
||||
|
||||
if(entry_count <= CONFIG_MAX_CACHED_LOG_ENTRIES)
|
||||
entries += entry
|
||||
log_ring += entry
|
||||
else
|
||||
log_ring[ring_write_index] = entry
|
||||
ring_write_index++
|
||||
if(ring_write_index > CONFIG_MAX_CACHED_LOG_ENTRIES)
|
||||
ring_write_index = 1
|
||||
|
||||
/// Allows for category specific file splitting. Needs to accept a null entry for the default file.
|
||||
/// If master_category it will always return the output of master_category.get_output_file(entry)
|
||||
@@ -68,3 +77,31 @@ GENERAL_PROTECT_DATUM(/datum/log_category)
|
||||
entry.write_readable_entry_to_file(get_output_file(entry, "log"), format_internally = internal_formatting)
|
||||
|
||||
entry.write_entry_to_file(get_output_file(entry))
|
||||
|
||||
/datum/log_category/proc/access_logs()
|
||||
var/list/result = list()
|
||||
var/count = min(entry_count, CONFIG_MAX_CACHED_LOG_ENTRIES)
|
||||
|
||||
for(var/i = 0, i < count, i++)
|
||||
var/index = ((ring_write_index - count + i - 1 + CONFIG_MAX_CACHED_LOG_ENTRIES) % CONFIG_MAX_CACHED_LOG_ENTRIES) + 1
|
||||
result += log_ring[index]
|
||||
|
||||
return result
|
||||
|
||||
/datum/log_category/proc/build_ui_log_entries()
|
||||
var/list/entries = list()
|
||||
var/count = min(entry_count, CONFIG_MAX_CACHED_LOG_ENTRIES)
|
||||
|
||||
for(var/i = 0, i < count, i++)
|
||||
var/index = ((ring_write_index - count + i - 1 + CONFIG_MAX_CACHED_LOG_ENTRIES) % CONFIG_MAX_CACHED_LOG_ENTRIES) + 1
|
||||
var/datum/log_entry/entry = log_ring[index]
|
||||
|
||||
entries += list(list(
|
||||
"id" = entry.id,
|
||||
"message" = entry.message,
|
||||
"timestamp" = entry.timestamp,
|
||||
"data" = entry.data,
|
||||
"semver" = entry.semver_store
|
||||
))
|
||||
|
||||
return entries
|
||||
|
||||
@@ -79,16 +79,7 @@ ADMIN_VERB(log_viewer_new, R_ADMIN|R_MOD|R_DEBUG, "View Round Logs", "View the r
|
||||
category = log_categories[category]
|
||||
var/list/category_data = list()
|
||||
|
||||
var/list/entries = list()
|
||||
for(var/datum/log_entry/entry as anything in category.entries)
|
||||
entries += list(list(
|
||||
"id" = entry.id,
|
||||
"message" = entry.message,
|
||||
"timestamp" = entry.timestamp,
|
||||
"data" = entry.data,
|
||||
"semver" = entry.semver_store,
|
||||
))
|
||||
category_data["entries"] = entries
|
||||
category_data["entries"] = category.build_ui_log_entries()
|
||||
category_data["entry_count"] = category.entry_count
|
||||
|
||||
category_map[category.category] = category_data
|
||||
|
||||
@@ -825,7 +825,7 @@ GLOBAL_LIST_EMPTY(light_type_cache)
|
||||
else if(TK in user.mutations)
|
||||
to_chat(user, "You telekinetically remove the light [get_fitting_name()].")
|
||||
else
|
||||
to_chat(user, "You try to remove the light [get_fitting_name()], but it's too hot and you don't want to burn your hand.")
|
||||
to_chat(user, "You try to remove the [get_fitting_name()], but it's too hot and you don't want to burn your hand.")
|
||||
return // if burned, don't remove the light
|
||||
else
|
||||
to_chat(user, "You remove the light [get_fitting_name()].")
|
||||
|
||||
@@ -172,6 +172,7 @@ class StorageProxy implements StorageBackend {
|
||||
setTimeout(async () => {
|
||||
const hub = new HubStorageBackend();
|
||||
|
||||
// Migrate these existing settings from byondstorage to the IFrame
|
||||
for (const setting of [
|
||||
'panel-settings',
|
||||
'chat-state',
|
||||
|
||||
Reference in New Issue
Block a user