mirror of
https://github.com/hexedtech/codemp.git
synced 2024-11-22 07:14:50 +01:00
fix: dont use color codes in logger
This commit is contained in:
parent
f5f0a7edf1
commit
864348bef4
2 changed files with 12 additions and 27 deletions
1
.github/workflows/lua.yml
vendored
1
.github/workflows/lua.yml
vendored
|
@ -4,6 +4,7 @@ on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- stable
|
- stable
|
||||||
|
- dev
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
|
|
|
@ -451,6 +451,15 @@ impl Write for LuaLoggerProducer {
|
||||||
// TODO can we make this less verbose?
|
// TODO can we make this less verbose?
|
||||||
fn logger(_: &Lua, (printer, debug): (LuaValue, Option<bool>)) -> LuaResult<bool> {
|
fn logger(_: &Lua, (printer, debug): (LuaValue, Option<bool>)) -> LuaResult<bool> {
|
||||||
let level = if debug.unwrap_or_default() { tracing::Level::DEBUG } else {tracing::Level::INFO };
|
let level = if debug.unwrap_or_default() { tracing::Level::DEBUG } else {tracing::Level::INFO };
|
||||||
|
let format = tracing_subscriber::fmt::format()
|
||||||
|
.with_level(true)
|
||||||
|
.with_target(true)
|
||||||
|
.with_thread_ids(false)
|
||||||
|
.with_thread_names(false)
|
||||||
|
.with_file(false)
|
||||||
|
.with_line_number(false)
|
||||||
|
.with_source_location(false);
|
||||||
|
|
||||||
let success = match printer {
|
let success = match printer {
|
||||||
LuaValue::Boolean(_)
|
LuaValue::Boolean(_)
|
||||||
| LuaValue::LightUserData(_)
|
| LuaValue::LightUserData(_)
|
||||||
|
@ -461,15 +470,6 @@ fn logger(_: &Lua, (printer, debug): (LuaValue, Option<bool>)) -> LuaResult<bool
|
||||||
| LuaValue::UserData(_)
|
| LuaValue::UserData(_)
|
||||||
| LuaValue::Error(_) => return Err(LuaError::BindError), // TODO full BadArgument type??
|
| LuaValue::Error(_) => return Err(LuaError::BindError), // TODO full BadArgument type??
|
||||||
LuaValue::Nil => {
|
LuaValue::Nil => {
|
||||||
let format = tracing_subscriber::fmt::format()
|
|
||||||
.with_level(true)
|
|
||||||
.with_target(true)
|
|
||||||
.with_thread_ids(true)
|
|
||||||
.with_thread_names(true)
|
|
||||||
.with_ansi(true)
|
|
||||||
.with_file(false)
|
|
||||||
.with_line_number(false)
|
|
||||||
.with_source_location(false);
|
|
||||||
tracing_subscriber::fmt()
|
tracing_subscriber::fmt()
|
||||||
.event_format(format)
|
.event_format(format)
|
||||||
.with_max_level(level)
|
.with_max_level(level)
|
||||||
|
@ -479,37 +479,21 @@ fn logger(_: &Lua, (printer, debug): (LuaValue, Option<bool>)) -> LuaResult<bool
|
||||||
},
|
},
|
||||||
LuaValue::String(path) => {
|
LuaValue::String(path) => {
|
||||||
let logfile = std::fs::File::create(path.to_string_lossy()).map_err(|e| LuaError::RuntimeError(e.to_string()))?;
|
let logfile = std::fs::File::create(path.to_string_lossy()).map_err(|e| LuaError::RuntimeError(e.to_string()))?;
|
||||||
let format = tracing_subscriber::fmt::format()
|
|
||||||
.with_level(true)
|
|
||||||
.with_target(true)
|
|
||||||
.with_thread_ids(true)
|
|
||||||
.with_thread_names(true)
|
|
||||||
.with_ansi(false)
|
|
||||||
.with_file(false)
|
|
||||||
.with_line_number(false)
|
|
||||||
.with_source_location(false);
|
|
||||||
tracing_subscriber::fmt()
|
tracing_subscriber::fmt()
|
||||||
.event_format(format)
|
.event_format(format)
|
||||||
.with_max_level(level)
|
.with_max_level(level)
|
||||||
.with_writer(Mutex::new(logfile))
|
.with_writer(Mutex::new(logfile))
|
||||||
|
.with_ansi(false)
|
||||||
.try_init()
|
.try_init()
|
||||||
.is_ok()
|
.is_ok()
|
||||||
},
|
},
|
||||||
LuaValue::Function(cb) => {
|
LuaValue::Function(cb) => {
|
||||||
let (tx, mut rx) = mpsc::unbounded_channel();
|
let (tx, mut rx) = mpsc::unbounded_channel();
|
||||||
let format = tracing_subscriber::fmt::format()
|
|
||||||
.with_level(true)
|
|
||||||
.with_target(true)
|
|
||||||
.with_thread_ids(false)
|
|
||||||
.with_thread_names(false)
|
|
||||||
.with_ansi(false)
|
|
||||||
.with_file(false)
|
|
||||||
.with_line_number(false)
|
|
||||||
.with_source_location(false);
|
|
||||||
let res = tracing_subscriber::fmt()
|
let res = tracing_subscriber::fmt()
|
||||||
.event_format(format)
|
.event_format(format)
|
||||||
.with_max_level(level)
|
.with_max_level(level)
|
||||||
.with_writer(Mutex::new(LuaLoggerProducer(tx)))
|
.with_writer(Mutex::new(LuaLoggerProducer(tx)))
|
||||||
|
.with_ansi(false)
|
||||||
.try_init()
|
.try_init()
|
||||||
.is_ok();
|
.is_ok();
|
||||||
if res {
|
if res {
|
||||||
|
|
Loading…
Reference in a new issue