diff --git a/baystation12.dme b/baystation12.dme index 72a1ad4e9fb52..20c357e3dc5bc 100644 --- a/baystation12.dme +++ b/baystation12.dme @@ -420,6 +420,7 @@ #include "code\datums\repositories\attack_logs.dm" #include "code\datums\repositories\cameras.dm" #include "code\datums\repositories\client.dm" +#include "code\datums\repositories\computer_logs.dm" #include "code\datums\repositories\follow.dm" #include "code\datums\repositories\images.dm" #include "code\datums\repositories\mobs.dm" @@ -1404,6 +1405,7 @@ #include "code\modules\admin\secrets\fun_secrets\power_all_smes.dm" #include "code\modules\admin\secrets\fun_secrets\waddle.dm" #include "code\modules\admin\secrets\investigation\attack_logs.dm" +#include "code\modules\admin\secrets\investigation\computer_logs.dm" #include "code\modules\admin\secrets\investigation\view_persistant.dm" #include "code\modules\admin\verbs\adminhelp.dm" #include "code\modules\admin\verbs\adminjump.dm" diff --git a/code/_helpers/logging.dm b/code/_helpers/logging.dm index 25be7069c7681..0ce8379d29c5f 100644 --- a/code/_helpers/logging.dm +++ b/code/_helpers/logging.dm @@ -114,6 +114,9 @@ var/global/log_end= world.system_type == UNIX ? ascii2text(13) : "" to_world_log("## UNIT_TEST ##: [text]") log_debug(text) +/proc/log_computer_command(text) + if (config.log_computer_commands) + game_log("COMPUTER_COMMAND", text) //This replaces world.log so it displays both in DD and the file /proc/log_world(text) diff --git a/code/controllers/configuration.dm b/code/controllers/configuration.dm index 60cc5538620ee..1705a5ab05fdf 100644 --- a/code/controllers/configuration.dm +++ b/code/controllers/configuration.dm @@ -54,10 +54,15 @@ /// log world.log to game log var/static/log_world_output = FALSE -//[SIERRA-ADD] + + //[SIERRA-ADD] /// log signals messages var/static/log_signals = FALSE -//[/SIERRA-ADD] + //[/SIERRA-ADD] + + /// log computer commands + var/static/log_computer_commands = FALSE + /// Allows admins with relevant permissions to have their own ooc colour var/static/allow_admin_ooccolor = FALSE @@ -550,6 +555,8 @@ log_hrefs = TRUE if ("log_runtime") log_runtime = TRUE + if ("log_computer_commands") + log_computer_commands = TRUE if ("generate_asteroid") generate_map = TRUE if ("no_click_cooldown") diff --git a/code/datums/repositories/computer_logs.dm b/code/datums/repositories/computer_logs.dm new file mode 100644 index 0000000000000..c7a24e2b62f73 --- /dev/null +++ b/code/datums/repositories/computer_logs.dm @@ -0,0 +1,26 @@ +var/global/repository/computer_logs/computer_log_repository = new() + +/repository/computer_logs + var/list/computer_logs_ + +/repository/computer_logs/New() + ..() + computer_logs_ = list() + +/repository/computer_logs/proc/store_computer_log(mob/user, turf/location, command) + // Newest logs first + computer_logs_.Insert(1, new/datum/computer_log(user, location, command)) + +/datum/computer_log + var/station_time + var/datum/mob_lite/user + var/turf/location + var/command + +/datum/computer_log/New(mob/user, location, command) + station_time = time_stamp() + src.user = mob_repository.get_lite_mob(user) + src.location = location + src.command = command + + location = get_turf(user) diff --git a/code/modules/admin/secrets/investigation/computer_logs.dm b/code/modules/admin/secrets/investigation/computer_logs.dm new file mode 100644 index 0000000000000..a6aace9ac71db --- /dev/null +++ b/code/modules/admin/secrets/investigation/computer_logs.dm @@ -0,0 +1,35 @@ +/datum/admin_secret_item/investigation/computer_logs + name = "Computer Logs" + var/list/filters_per_client + +/datum/admin_secret_item/investigation/computer_logs/New() + ..() + filters_per_client = list() + +/datum/admin_secret_item/investigation/computer_logs/execute(mob/user) + . = ..() + if(!.) + return + var/dat = list() + dat += "Refresh" + dat += "
" + dat += "" + dat += "" + + for(var/log in computer_log_repository.computer_logs_) + var/datum/computer_log/al = log + + dat += "" + + if(al.user) + dat += "" + + dat += "" + dat += "
TimeUserCommand
[al.station_time][al.user.key_name(check_if_offline = FALSE)] PP[al.command]" + if(al.location) + dat += " JMP" + dat += "
" + + var/datum/browser/popup = new(user, "computer_attack_logs", "Computer Logs", 800, 400) + popup.set_content(jointext(dat, null)) + popup.open() diff --git a/code/modules/modular_computers/terminal/terminal.dm b/code/modules/modular_computers/terminal/terminal.dm index b92a8813f7e2b..01b58a0ec0a2b 100644 --- a/code/modules/modular_computers/terminal/terminal.dm +++ b/code/modules/modular_computers/terminal/terminal.dm @@ -67,6 +67,8 @@ var/input = sanitize(href_list["input"]) history += "> [input]" var/output = parse(input, usr) + log_computer_command("[key_name(usr)]: [input]") + computer_log_repository.store_computer_log(usr, get_turf(computer.holder), input) if(QDELETED(src)) // Check for exit. return TOPIC_HANDLED history += output diff --git a/config/example/config.txt b/config/example/config.txt index b670f8379a40e..6d1edc4963eeb 100644 --- a/config/example/config.txt +++ b/config/example/config.txt @@ -76,6 +76,9 @@ LOG_ATTACK ## log admin warning messages ##LOG_ADMINWARN ## Also duplicates a bunch of other messages. +## log computer commands +# LOG_COMPUTER_COMMANDS + ## Log all timers on timer auto reset # LOG_TIMERS_ON_BUCKET_RESET