Port Rust-g DLL and use it for logging (#5394)

This commit is contained in:
Mykhailo Bykhovtsev
2018-10-12 16:46:19 +02:00
committed by Werner
parent 2bb70110df
commit f179568e1d
7 changed files with 93 additions and 7 deletions
+10 -1
View File
@@ -8,6 +8,7 @@ env:
MACRO_COUNT=77
FLYWAY_BUILD="5.1.4"
NODE_VERSION=10
RUST_G_VERSION="0.4.1"
matrix:
- USE_MAP=aurora
- USE_MAP=runtime
@@ -18,6 +19,7 @@ cache:
- $HOME/BYOND-${BYOND_MAJOR}.${BYOND_MINOR}
- $HOME/flyway-${FLYWAY_BUILD}
- vueui/dist
- $HOME/rust_g-${RUST_G_VERSION}
addons:
mariadb: '10.1'
@@ -26,6 +28,9 @@ addons:
- libc6-i386
- libgcc1:i386
- libstdc++6:i386
- libssl-dev:i386
- pkg-config:i386
- gcc-multilib
node_js:
- "10"
@@ -38,8 +43,10 @@ install:
- ./install-byond.sh
- chmod +x ./install-flyway.sh
- ./install-flyway.sh
- export LD_LIBRARY_PATH=./:$LD_LIBRARY_PATH
- export LD_LIBRARY_PATH=./:$HOME/rust_g-$RUST_G_VERSION:$LD_LIBRARY_PATH
- shopt -s globstar
- chmod +x ./scripts/rust_g.sh
- ./scripts/rust_g.sh
stages:
- code check
@@ -63,6 +70,8 @@ jobs:
install:
- chmod +x ./vueui/install
- ./vueui/install
- chmod +x ./scripts/rust_g.sh
- ./scripts/rust_g.sh
script:
- (! grep 'step_[xy]' maps/**/*.dmm)
- (! find nano/templates/ -type f -exec md5sum {} + | sort | uniq -D -w 32 | grep nano)
+2 -1
View File
@@ -17,6 +17,7 @@
"data"
],
"dlls": [
"libmysql.dll"
"libmysql.dll",
"rust_g.dll"
]
}
+21 -2
View File
@@ -1,5 +1,6 @@
//print an error message to world.log
#define RUST_G "rust_g" // Using Rust g dll to log faster with less CPU usage.
#define WRITE_LOG(log, text) call(RUST_G, "log_write")(log, text)
// On Linux/Unix systems the line endings are LF, on windows it's CRLF, admins that don't use notepad++
// will get logs that are one big line if the system is Linux and they are using notepad. This solves it by adding CR to every line ending
@@ -15,9 +16,24 @@
/var/global/log_end = world.system_type == UNIX ? ascii2text(13) : ""
// logging.dm
/proc/log_startup()
var/static/already_logged = FALSE
if (!already_logged)
WRITE_LOG(diary, "[log_end]\n[log_end]\nStarting up. (ID: [game_id]) [time2text(world.timeofday, "hh:mm.ss")][log_end]\n---------------------[log_end]")
already_logged = TRUE
else
crash_with("log_startup() was called more then once")
/proc/log_topic(T, addr, master, key, var/list/queryparams)
WRITE_LOG(diary, "TOPIC: \"[T]\", from:[addr], master:[master], key:[key], auth:[queryparams["auth"] ? queryparams["auth"] : "null"] [log_end]")
/proc/error(msg)
world.log << "## ERROR: [msg][log_end]"
/proc/shutdown_logging()
call(RUST_G, "log_close_all")()
#define WARNING(MSG) warning("[MSG] in [__FILE__] at line [__LINE__] src: [src] usr: [usr].")
//print a warning message to world.log
/proc/warning(msg)
@@ -28,7 +44,7 @@
world.log << "## TESTING: [msg][log_end]"
/proc/game_log(category, text)
diary << "\[[time_stamp()]] [game_id] [category]: [text][log_end]"
WRITE_LOG(diary, "\[[time_stamp()]] [game_id] [category]: [text][log_end]")
/proc/log_admin(text,level=SEVERITY_NOTICE,ckey="",admin_key="",ckey_target="")
admin_log.Add(text)
@@ -260,3 +276,6 @@
/proc/key_name_admin(var/whom, var/include_name = 1)
return key_name(whom, 1, include_name, 1)
#undef RUST_G
#undef WRITE_LOG
+4 -3
View File
@@ -63,8 +63,8 @@ var/global/datum/global_init/init = new ()
//logs
diary_date_string = time2text(world.realtime, "YYYY/MM-Month/DD-Day")
href_logfile = file("data/logs/[diary_date_string] hrefs.htm")
diary = file("data/logs/[diary_date_string].log")
diary << "[log_end]\n[log_end]\nStarting up. (ID: [game_id]) [time2text(world.timeofday, "hh:mm.ss")][log_end]\n---------------------[log_end]"
diary = "data/logs/[diary_date_string].log"
log_startup()
changelog_hash = md5('html/changelog.html') //used for telling if the changelog has changed recently
if(config.log_runtime)
@@ -115,7 +115,7 @@ var/list/world_api_rate_limit = list()
queryparams = list()
log_debug("API: Request Received - from:[addr], master:[master], key:[key]")
diary << "TOPIC: \"[T]\", from:[addr], master:[master], key:[key], auth:[queryparams["auth"] ? queryparams["auth"] : "null"] [log_end]"
log_topic(T, addr, master, key, queryparams)
// TGS topic hook. Returns if successful, expects old-style serialization.
var/tgs_topic_return = TgsTopic(T)
@@ -192,6 +192,7 @@ var/list/world_api_rate_limit = list()
world.TgsReboot()
Master.Shutdown()
shutdown_logging()
if(config.server) //if you set a server location in config.txt, it sends you there instead of trying to reconnect to the same world address. -- NeoFite
for(var/client/C in clients)
+37
View File
@@ -0,0 +1,37 @@
################################
# Example Changelog File
#
# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb.
#
# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.)
# When it is, any changes listed below will disappear.
#
# Valid Prefixes:
# bugfix
# wip (For works in progress)
# tweak
# soundadd
# sounddel
# rscadd (general adding of nice things)
# rscdel (general deleting of nice things)
# imageadd
# imagedel
# maptweak
# spellcheck (typo fixes)
# experiment
# balance
#################################
# Your name.
author: PoZe
# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again.
delete-after: True
# Any changes you've made. See valid prefix list above.
# INDENT WITH TWO SPACES. NOT TABS. SPACES.
# SCREW THIS UP AND IT WON'T WORK.
# Also, all entries are changed into a single [] after a master changelog generation. Just remove the brackets when you add new entries.
# Please surround your changes in double quotes ("), as certain characters otherwise screws up compiling. The quotes will not show up in the changelog.
changes:
- tweak: "Logging now is using fast RUST DLL which will reduce CPU usage and reduce lag during high player count rounds with bunch of logs."
BIN
View File
Binary file not shown.
+19
View File
@@ -0,0 +1,19 @@
#!/usr/bin/env bash
if [ -f $HOME/rust_g-$RUST_G_VERSION/rust_g ]; then
echo "rust_g already cached."
exit 0
fi
set -e
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-host i686-unknown-linux-gnu
source ~/.profile
git clone --branch $RUST_G_VERSION https://github.com/tgstation/rust-g
cd rust-g
cargo build --release
mkdir -p ~/.byond/bin
cp $PWD/target/release/librust_g.so $HOME/rust_g-$RUST_G_VERSION/rust_g