mirror of
https://github.com/zaphar/kitchen.git
synced 2025-07-22 19:40:14 -04:00
Dont use debug logging by default on web
This commit is contained in:
parent
6d0aae2c92
commit
98f94b555c
14
flake.nix
14
flake.nix
@ -44,12 +44,26 @@
|
|||||||
#root = (pkgs.callPackage gitignore { }).gitignoreSource ./.;
|
#root = (pkgs.callPackage gitignore { }).gitignoreSource ./.;
|
||||||
root = ./.;
|
root = ./.;
|
||||||
});
|
});
|
||||||
|
kitchenWasmDebug = kitchenWasmGen {
|
||||||
|
inherit pkgs rust-wasm version;
|
||||||
|
features = "--features debug_logs";
|
||||||
|
};
|
||||||
|
kitchenDebug = (kitchenGen {
|
||||||
|
inherit pkgs version naersk-lib rust-wasm;
|
||||||
|
kitchenWasm = kitchenWasmDebug;
|
||||||
|
# Because it's a workspace we need the other crates available as source
|
||||||
|
# TODO(jwall): gitignoreSource is broken right now due to being impure.
|
||||||
|
#root = (pkgs.callPackage gitignore { }).gitignoreSource ./.;
|
||||||
|
root = ./.;
|
||||||
|
});
|
||||||
module = moduleGen {inherit kitchen;};
|
module = moduleGen {inherit kitchen;};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
packages = {
|
packages = {
|
||||||
inherit kitchenWasm
|
inherit kitchenWasm
|
||||||
kitchen
|
kitchen
|
||||||
|
kitchenWasmDebug
|
||||||
|
kitchenDebug
|
||||||
;
|
;
|
||||||
};
|
};
|
||||||
defaultPackage = kitchen;
|
defaultPackage = kitchen;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
{pkgs? (import <nixpkgs>) {},
|
{pkgs? (import <nixpkgs>) {},
|
||||||
version ? "0.2.1",
|
version ? "0.2.1",
|
||||||
|
features ? "",
|
||||||
rust-wasm,
|
rust-wasm,
|
||||||
}:
|
}:
|
||||||
with pkgs;
|
with pkgs;
|
||||||
@ -35,7 +36,8 @@ stdenv.mkDerivation {
|
|||||||
mkdir -p $out
|
mkdir -p $out
|
||||||
cd web
|
cd web
|
||||||
cp -r static $out
|
cp -r static $out
|
||||||
RUST_LOG=info wasm-pack build --mode no-install --release --target web --out-dir $out;
|
RUST_LOG=info wasm-pack build --mode no-install --release --target web --out-dir $out ${features};
|
||||||
cp -r index.html $out
|
cp -r index.html $out
|
||||||
|
cp -r favicon.ico $out
|
||||||
'';
|
'';
|
||||||
}
|
}
|
2
run.sh
2
run.sh
@ -13,5 +13,5 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
EXAMPLES=${EXAMPLES:-../examples}
|
EXAMPLES=${EXAMPLES:-../examples}
|
||||||
echo Starting api server serving ${EXAMPLES}
|
echo Starting api server serving ${EXAMPLES}
|
||||||
nix run .\#kitchen -- --verbose debug serve --dir ${EXAMPLES} --tls --cert ~/tls-certs/localhost+2.pem --cert_key ~/tls-certs/localhost+2-key.pem
|
nix run .\#kitchenDebug -- --verbose debug serve --dir ${EXAMPLES} --tls --cert ~/tls-certs/localhost+2.pem --cert_key ~/tls-certs/localhost+2-key.pem
|
||||||
# This is ghetto but I'm doing it anyway
|
# This is ghetto but I'm doing it anyway
|
||||||
|
@ -7,6 +7,7 @@ edition = "2021"
|
|||||||
ssr = []
|
ssr = []
|
||||||
web = []
|
web = []
|
||||||
default = ["web"]
|
default = ["web"]
|
||||||
|
debug_logs = []
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
[lib]
|
[lib]
|
||||||
|
@ -26,19 +26,23 @@ use web::UI;
|
|||||||
|
|
||||||
fn configure_tracing() {
|
fn configure_tracing() {
|
||||||
console_error_panic_hook::set_once();
|
console_error_panic_hook::set_once();
|
||||||
use tracing_subscriber::fmt::format::Pretty;
|
use tracing::Level;
|
||||||
use tracing_subscriber::prelude::*;
|
use tracing_subscriber::{filter::LevelFilter, fmt::format::Pretty, prelude::*};
|
||||||
use tracing_web::{performance_layer, MakeConsoleWriter};
|
use tracing_web::{performance_layer, MakeConsoleWriter};
|
||||||
let fmt_layer = tracing_subscriber::fmt::layer()
|
let fmt_layer = tracing_subscriber::fmt::layer()
|
||||||
.with_ansi(false)
|
.with_ansi(false)
|
||||||
.without_time()
|
.without_time()
|
||||||
//.with_timer(UtcTime::rfc_3339()) // std::time is not available in browsers
|
.with_writer(MakeConsoleWriter) // write events to the console
|
||||||
.with_writer(MakeConsoleWriter); // write events to the console
|
.with_filter(LevelFilter::from(if cfg!(feature = "debug_logs") {
|
||||||
|
Level::DEBUG
|
||||||
|
} else {
|
||||||
|
Level::INFO
|
||||||
|
}));
|
||||||
let perf_layer = performance_layer().with_details_from_fields(Pretty::default());
|
let perf_layer = performance_layer().with_details_from_fields(Pretty::default());
|
||||||
|
|
||||||
tracing_subscriber::registry()
|
tracing_subscriber::registry()
|
||||||
.with(fmt_layer)
|
|
||||||
.with(perf_layer)
|
.with(perf_layer)
|
||||||
|
.with(fmt_layer)
|
||||||
.init();
|
.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user