mirror of
https://gitlab.com/veilid/veilid.git
synced 2025-02-22 15:39:54 -05:00
more cleanup
This commit is contained in:
parent
c106d324c8
commit
d96e5a131c
2
external/cursive-flexi-logger-view
vendored
2
external/cursive-flexi-logger-view
vendored
@ -1 +1 @@
|
|||||||
Subproject commit a1ff362346bd93955d9126893e4f6afb21f00881
|
Subproject commit 16ac289d156b327a1a3a2feeef103e3212e453b5
|
@ -101,6 +101,7 @@ fn main() -> Result<(), String> {
|
|||||||
{
|
{
|
||||||
let mut specbuilder = LogSpecBuilder::new();
|
let mut specbuilder = LogSpecBuilder::new();
|
||||||
specbuilder.default(settings::convert_loglevel(settings.logging.level));
|
specbuilder.default(settings::convert_loglevel(settings.logging.level));
|
||||||
|
specbuilder.module("cursive", LevelFilter::Off);
|
||||||
specbuilder.module("cursive_core", LevelFilter::Off);
|
specbuilder.module("cursive_core", LevelFilter::Off);
|
||||||
specbuilder.module("cursive_buffered_backend", LevelFilter::Off);
|
specbuilder.module("cursive_buffered_backend", LevelFilter::Off);
|
||||||
specbuilder.module("mio", LevelFilter::Off);
|
specbuilder.module("mio", LevelFilter::Off);
|
||||||
|
@ -24,7 +24,6 @@ pub fn rpc_error_protocol<T: AsRef<str>>(x: T) -> RPCError {
|
|||||||
}
|
}
|
||||||
pub fn rpc_error_capnp_error(e: capnp::Error) -> RPCError {
|
pub fn rpc_error_capnp_error(e: capnp::Error) -> RPCError {
|
||||||
error!("RPCError Protocol: capnp error: {}", &e.description);
|
error!("RPCError Protocol: capnp error: {}", &e.description);
|
||||||
panic!("wtf");
|
|
||||||
RPCError::Protocol(e.description)
|
RPCError::Protocol(e.description)
|
||||||
}
|
}
|
||||||
pub fn rpc_error_capnp_notinschema(e: capnp::NotInSchema) -> RPCError {
|
pub fn rpc_error_capnp_notinschema(e: capnp::NotInSchema) -> RPCError {
|
||||||
|
@ -290,7 +290,6 @@ pub async fn test_config() {
|
|||||||
let inner = vc.get();
|
let inner = vc.get();
|
||||||
assert_eq!(inner.program_name, String::from("Veilid"));
|
assert_eq!(inner.program_name, String::from("Veilid"));
|
||||||
assert_eq!(inner.namespace, String::from(""));
|
assert_eq!(inner.namespace, String::from(""));
|
||||||
assert_eq!(inner.api_log_level, VeilidConfigLogLevel::Off);
|
|
||||||
assert_eq!(inner.capabilities.protocol_udp, true);
|
assert_eq!(inner.capabilities.protocol_udp, true);
|
||||||
assert_eq!(inner.capabilities.protocol_connect_tcp, true);
|
assert_eq!(inner.capabilities.protocol_connect_tcp, true);
|
||||||
assert_eq!(inner.capabilities.protocol_accept_tcp, true);
|
assert_eq!(inner.capabilities.protocol_accept_tcp, true);
|
||||||
|
@ -23,7 +23,6 @@ pub use network_manager::NetworkManager;
|
|||||||
pub use routing_table::RoutingTable;
|
pub use routing_table::RoutingTable;
|
||||||
pub use rpc_processor::StatusAnswer;
|
pub use rpc_processor::StatusAnswer;
|
||||||
|
|
||||||
use api_tracing_layer::*;
|
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
use core_context::{api_shutdown, VeilidCoreContext};
|
use core_context::{api_shutdown, VeilidCoreContext};
|
||||||
use enumset::*;
|
use enumset::*;
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
use super::*;
|
use super::*;
|
||||||
use core::fmt::Debug;
|
use core::fmt::Debug;
|
||||||
|
|
||||||
#[instrument(level = "trace", ret, err)]
|
// XXX: Don't trace these functions as they are used in the transfer of API logs, which will recurse!
|
||||||
|
|
||||||
|
// #[instrument(level = "trace", ret, err)]
|
||||||
pub fn deserialize_json<'a, T: de::Deserialize<'a> + Debug>(
|
pub fn deserialize_json<'a, T: de::Deserialize<'a> + Debug>(
|
||||||
arg: &'a str,
|
arg: &'a str,
|
||||||
) -> Result<T, VeilidAPIError> {
|
) -> Result<T, VeilidAPIError> {
|
||||||
@ -15,7 +17,7 @@ pub fn deserialize_json<'a, T: de::Deserialize<'a> + Debug>(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(level = "trace", ret, err)]
|
// #[instrument(level = "trace", ret, err)]
|
||||||
pub fn deserialize_opt_json<T: de::DeserializeOwned + Debug>(
|
pub fn deserialize_opt_json<T: de::DeserializeOwned + Debug>(
|
||||||
arg: Option<String>,
|
arg: Option<String>,
|
||||||
) -> Result<T, VeilidAPIError> {
|
) -> Result<T, VeilidAPIError> {
|
||||||
@ -29,7 +31,7 @@ pub fn deserialize_opt_json<T: de::DeserializeOwned + Debug>(
|
|||||||
deserialize_json(arg)
|
deserialize_json(arg)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(level = "trace", ret)]
|
// #[instrument(level = "trace", ret)]
|
||||||
pub fn serialize_json<T: Serialize + Debug>(val: T) -> String {
|
pub fn serialize_json<T: Serialize + Debug>(val: T) -> String {
|
||||||
match serde_json::to_string(&val) {
|
match serde_json::to_string(&val) {
|
||||||
Ok(v) => v,
|
Ok(v) => v,
|
||||||
|
@ -244,7 +244,6 @@ impl Default for VeilidConfigLogLevel {
|
|||||||
pub struct VeilidConfigInner {
|
pub struct VeilidConfigInner {
|
||||||
pub program_name: String,
|
pub program_name: String,
|
||||||
pub namespace: String,
|
pub namespace: String,
|
||||||
pub api_log_level: VeilidConfigLogLevel,
|
|
||||||
pub capabilities: VeilidConfigCapabilities,
|
pub capabilities: VeilidConfigCapabilities,
|
||||||
pub protected_store: VeilidConfigProtectedStore,
|
pub protected_store: VeilidConfigProtectedStore,
|
||||||
pub table_store: VeilidConfigTableStore,
|
pub table_store: VeilidConfigTableStore,
|
||||||
@ -309,7 +308,6 @@ impl VeilidConfig {
|
|||||||
let mut inner = self.inner.write();
|
let mut inner = self.inner.write();
|
||||||
get_config!(inner.program_name);
|
get_config!(inner.program_name);
|
||||||
get_config!(inner.namespace);
|
get_config!(inner.namespace);
|
||||||
get_config!(inner.api_log_level);
|
|
||||||
get_config!(inner.capabilities.protocol_udp);
|
get_config!(inner.capabilities.protocol_udp);
|
||||||
get_config!(inner.capabilities.protocol_connect_tcp);
|
get_config!(inner.capabilities.protocol_connect_tcp);
|
||||||
get_config!(inner.capabilities.protocol_accept_tcp);
|
get_config!(inner.capabilities.protocol_accept_tcp);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use super::*;
|
use super::*;
|
||||||
use crate::xx::*;
|
use crate::xx::*;
|
||||||
use tracing::level_filters::LevelFilter;
|
use tracing::level_filters::LevelFilter;
|
||||||
use tracing::subscriber;
|
use tracing::subscriber::Interest;
|
||||||
use tracing_subscriber::layer;
|
use tracing_subscriber::layer;
|
||||||
|
|
||||||
struct VeilidLayerFilterInner {
|
struct VeilidLayerFilterInner {
|
||||||
@ -54,33 +54,35 @@ impl VeilidLayerFilter {
|
|||||||
}
|
}
|
||||||
callsite::rebuild_interest_cache();
|
callsite::rebuild_interest_cache();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
impl<S: tracing::Subscriber> layer::Filter<S> for VeilidLayerFilter {
|
fn interesting(&self, metadata: &tracing::Metadata<'_>) -> bool {
|
||||||
fn enabled(&self, metadata: &tracing::Metadata<'_>, _: &layer::Context<'_, S>) -> bool {
|
|
||||||
let inner = self.inner.read();
|
let inner = self.inner.read();
|
||||||
|
|
||||||
if *metadata.level() > inner.max_level {
|
if *metadata.level() > inner.max_level {
|
||||||
false
|
return false;
|
||||||
} else {
|
|
||||||
true
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fn callsite_enabled(
|
|
||||||
&self,
|
|
||||||
metadata: &'static tracing::Metadata<'static>,
|
|
||||||
) -> subscriber::Interest {
|
|
||||||
let inner = self.inner.read();
|
|
||||||
let skip = inner
|
let skip = inner
|
||||||
.ignore_list
|
.ignore_list
|
||||||
.iter()
|
.iter()
|
||||||
.any(|v| metadata.target().starts_with(&**v));
|
.any(|v| metadata.target().starts_with(&**v));
|
||||||
if skip {
|
if skip {
|
||||||
subscriber::Interest::never()
|
return false;
|
||||||
} else if *metadata.level() > inner.max_level {
|
}
|
||||||
subscriber::Interest::never()
|
|
||||||
|
true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<S: tracing::Subscriber> layer::Filter<S> for VeilidLayerFilter {
|
||||||
|
fn enabled(&self, metadata: &tracing::Metadata<'_>, _: &layer::Context<'_, S>) -> bool {
|
||||||
|
self.interesting(metadata)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn callsite_enabled(&self, metadata: &'static tracing::Metadata<'static>) -> Interest {
|
||||||
|
if self.interesting(metadata) {
|
||||||
|
Interest::always()
|
||||||
} else {
|
} else {
|
||||||
subscriber::Interest::always()
|
Interest::never()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ void main() {
|
|||||||
logsInConsole: true),
|
logsInConsole: true),
|
||||||
api: VeilidWASMConfigLoggingApi(
|
api: VeilidWASMConfigLoggingApi(
|
||||||
enabled: true, level: VeilidConfigLogLevel.info)));
|
enabled: true, level: VeilidConfigLogLevel.info)));
|
||||||
Veilid.instance.configureVeilidPlatform(platformConfig.json);
|
Veilid.instance.initializeVeilidCore(platformConfig.json);
|
||||||
} else {
|
} else {
|
||||||
var platformConfig = VeilidFFIConfig(
|
var platformConfig = VeilidFFIConfig(
|
||||||
logging: VeilidFFIConfigLogging(
|
logging: VeilidFFIConfigLogging(
|
||||||
@ -101,7 +101,7 @@ void main() {
|
|||||||
serviceName: "VeilidExample"),
|
serviceName: "VeilidExample"),
|
||||||
api: VeilidFFIConfigLoggingApi(
|
api: VeilidFFIConfigLoggingApi(
|
||||||
enabled: true, level: VeilidConfigLogLevel.info)));
|
enabled: true, level: VeilidConfigLogLevel.info)));
|
||||||
Veilid.instance.configureVeilidPlatform(platformConfig.json);
|
Veilid.instance.initializeVeilidCore(platformConfig.json);
|
||||||
}
|
}
|
||||||
|
|
||||||
runApp(MaterialApp(
|
runApp(MaterialApp(
|
||||||
|
@ -1297,7 +1297,7 @@ class VeilidVersion {
|
|||||||
abstract class Veilid {
|
abstract class Veilid {
|
||||||
static late Veilid instance = getVeilid();
|
static late Veilid instance = getVeilid();
|
||||||
|
|
||||||
void configureVeilidPlatform(Map<String, dynamic> platformConfigJson);
|
void initializeVeilidCore(Map<String, dynamic> platformConfigJson);
|
||||||
void changeLogLevel(String layer, VeilidConfigLogLevel logLevel);
|
void changeLogLevel(String layer, VeilidConfigLogLevel logLevel);
|
||||||
Stream<VeilidUpdate> startupVeilidCore(VeilidConfig config);
|
Stream<VeilidUpdate> startupVeilidCore(VeilidConfig config);
|
||||||
Future<VeilidState> getVeilidState();
|
Future<VeilidState> getVeilidState();
|
||||||
|
@ -29,9 +29,9 @@ typedef _FreeStringDart = void Function(Pointer<Utf8>);
|
|||||||
// fn initialize_veilid_flutter(dart_post_c_object_ptr: ffi::DartPostCObjectFnType)
|
// fn initialize_veilid_flutter(dart_post_c_object_ptr: ffi::DartPostCObjectFnType)
|
||||||
typedef _InitializeVeilidFlutterC = Void Function(Pointer<_DartPostCObject>);
|
typedef _InitializeVeilidFlutterC = Void Function(Pointer<_DartPostCObject>);
|
||||||
typedef _InitializeVeilidFlutterDart = void Function(Pointer<_DartPostCObject>);
|
typedef _InitializeVeilidFlutterDart = void Function(Pointer<_DartPostCObject>);
|
||||||
// fn configure_veilid_platform(platform_config: FfiStr)
|
// fn initialize_veilid_core(platform_config: FfiStr)
|
||||||
typedef _ConfigureVeilidPlatformC = Void Function(Pointer<Utf8>);
|
typedef _InitializeVeilidCoreC = Void Function(Pointer<Utf8>);
|
||||||
typedef _ConfigureVeilidPlatformDart = void Function(Pointer<Utf8>);
|
typedef _InitializeVeilidCoreDart = void Function(Pointer<Utf8>);
|
||||||
// fn change_log_level(layer: FfiStr, log_level: FfiStr)
|
// fn change_log_level(layer: FfiStr, log_level: FfiStr)
|
||||||
typedef _ChangeLogLevelC = Void Function(Pointer<Utf8>, Pointer<Utf8>);
|
typedef _ChangeLogLevelC = Void Function(Pointer<Utf8>, Pointer<Utf8>);
|
||||||
typedef _ChangeLogLevelDart = void Function(Pointer<Utf8>, Pointer<Utf8>);
|
typedef _ChangeLogLevelDart = void Function(Pointer<Utf8>, Pointer<Utf8>);
|
||||||
@ -245,7 +245,7 @@ class VeilidFFI implements Veilid {
|
|||||||
|
|
||||||
// Shared library functions
|
// Shared library functions
|
||||||
final _FreeStringDart _freeString;
|
final _FreeStringDart _freeString;
|
||||||
final _ConfigureVeilidPlatformDart _configureVeilidPlatform;
|
final _InitializeVeilidCoreDart _initializeVeilidCore;
|
||||||
final _ChangeLogLevelDart _changeLogLevel;
|
final _ChangeLogLevelDart _changeLogLevel;
|
||||||
final _StartupVeilidCoreDart _startupVeilidCore;
|
final _StartupVeilidCoreDart _startupVeilidCore;
|
||||||
final _GetVeilidStateDart _getVeilidState;
|
final _GetVeilidStateDart _getVeilidState;
|
||||||
@ -258,9 +258,8 @@ class VeilidFFI implements Veilid {
|
|||||||
: _dylib = dylib,
|
: _dylib = dylib,
|
||||||
_freeString =
|
_freeString =
|
||||||
dylib.lookupFunction<_FreeStringC, _FreeStringDart>('free_string'),
|
dylib.lookupFunction<_FreeStringC, _FreeStringDart>('free_string'),
|
||||||
_configureVeilidPlatform = dylib.lookupFunction<
|
_initializeVeilidCore = dylib.lookupFunction<_InitializeVeilidCoreC,
|
||||||
_ConfigureVeilidPlatformC,
|
_InitializeVeilidCoreDart>('initialize_veilid_core'),
|
||||||
_ConfigureVeilidPlatformDart>('configure_veilid_platform'),
|
|
||||||
_changeLogLevel =
|
_changeLogLevel =
|
||||||
dylib.lookupFunction<_ChangeLogLevelC, _ChangeLogLevelDart>(
|
dylib.lookupFunction<_ChangeLogLevelC, _ChangeLogLevelDart>(
|
||||||
'change_log_level'),
|
'change_log_level'),
|
||||||
@ -287,12 +286,12 @@ class VeilidFFI implements Veilid {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void configureVeilidPlatform(Map<String, dynamic> platformConfigJson) {
|
void initializeVeilidCore(Map<String, dynamic> platformConfigJson) {
|
||||||
var nativePlatformConfig =
|
var nativePlatformConfig =
|
||||||
jsonEncode(platformConfigJson, toEncodable: veilidApiToEncodable)
|
jsonEncode(platformConfigJson, toEncodable: veilidApiToEncodable)
|
||||||
.toNativeUtf8();
|
.toNativeUtf8();
|
||||||
|
|
||||||
_configureVeilidPlatform(nativePlatformConfig);
|
_initializeVeilidCore(nativePlatformConfig);
|
||||||
|
|
||||||
malloc.free(nativePlatformConfig);
|
malloc.free(nativePlatformConfig);
|
||||||
}
|
}
|
||||||
|
@ -20,11 +20,11 @@ Future<T> _wrapApiPromise<T>(Object p) {
|
|||||||
|
|
||||||
class VeilidJS implements Veilid {
|
class VeilidJS implements Veilid {
|
||||||
@override
|
@override
|
||||||
void configureVeilidPlatform(Map<String, dynamic> platformConfigJson) {
|
void initializeVeilidCore(Map<String, dynamic> platformConfigJson) {
|
||||||
var platformConfigJsonString =
|
var platformConfigJsonString =
|
||||||
jsonEncode(platformConfigJson, toEncodable: veilidApiToEncodable);
|
jsonEncode(platformConfigJson, toEncodable: veilidApiToEncodable);
|
||||||
js_util.callMethod(
|
js_util
|
||||||
wasm, "configure_veilid_platform", [platformConfigJsonString]);
|
.callMethod(wasm, "initialize_veilid_core", [platformConfigJsonString]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -142,7 +142,7 @@ pub extern "C" fn initialize_veilid_flutter(dart_post_c_object_ptr: ffi::DartPos
|
|||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
#[instrument]
|
#[instrument]
|
||||||
pub extern "C" fn configure_veilid_platform(platform_config: FfiStr) {
|
pub extern "C" fn initialize_veilid_core(platform_config: FfiStr) {
|
||||||
let platform_config = platform_config.into_opt_string();
|
let platform_config = platform_config.into_opt_string();
|
||||||
let platform_config: VeilidFFIConfig = veilid_core::deserialize_opt_json(platform_config)
|
let platform_config: VeilidFFIConfig = veilid_core::deserialize_opt_json(platform_config)
|
||||||
.expect("failed to deserialize plaform config json");
|
.expect("failed to deserialize plaform config json");
|
||||||
|
@ -34,7 +34,7 @@ logging:
|
|||||||
append: true
|
append: true
|
||||||
level: 'info'
|
level: 'info'
|
||||||
api:
|
api:
|
||||||
enabled: false
|
enabled: true
|
||||||
level: 'info'
|
level: 'info'
|
||||||
otlp:
|
otlp:
|
||||||
enabled: false
|
enabled: false
|
||||||
|
@ -108,7 +108,7 @@ where
|
|||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
pub struct VeilidWASMConfigLoggingPerformance {
|
pub struct VeilidWASMConfigLoggingPerformance {
|
||||||
pub enabled: bool,
|
pub enabled: bool,
|
||||||
pub level: veilid_core::VeilidLogLevel,
|
pub level: veilid_core::VeilidConfigLogLevel,
|
||||||
pub logs_in_timings: bool,
|
pub logs_in_timings: bool,
|
||||||
pub logs_in_console: bool,
|
pub logs_in_console: bool,
|
||||||
}
|
}
|
||||||
@ -116,7 +116,7 @@ pub struct VeilidWASMConfigLoggingPerformance {
|
|||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
pub struct VeilidWASMConfigLoggingAPI {
|
pub struct VeilidWASMConfigLoggingAPI {
|
||||||
pub enabled: bool,
|
pub enabled: bool,
|
||||||
pub level: veilid_core::VeilidLogLevel,
|
pub level: veilid_core::VeilidConfigLogLevel,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
@ -138,14 +138,14 @@ pub fn initialize_veilid_wasm() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[wasm_bindgen()]
|
#[wasm_bindgen()]
|
||||||
pub fn configure_veilid_platform(platform_config: String) {
|
pub fn initialize_veilid_core(platform_config: String) {
|
||||||
let platform_config: VeilidWASMConfig = veilid_core::deserialize_json(&platform_config)
|
let platform_config: VeilidWASMConfig = veilid_core::deserialize_json(&platform_config)
|
||||||
.expect("failed to deserialize plaform config json");
|
.expect("failed to deserialize platform config json");
|
||||||
|
|
||||||
// Set up subscriber and layers
|
// Set up subscriber and layers
|
||||||
let subscriber = Registry::default();
|
let subscriber = Registry::default();
|
||||||
let mut layers = Vec::new();
|
let mut layers = Vec::new();
|
||||||
let handles = (*FILTER_RELOAD_HANDLES).borrow_mut();
|
let mut filters = (*FILTERS).borrow_mut();
|
||||||
|
|
||||||
// Performance logger
|
// Performance logger
|
||||||
if platform_config.logging.performance.enabled {
|
if platform_config.logging.performance.enabled {
|
||||||
@ -162,7 +162,7 @@ pub fn configure_veilid_platform(platform_config: String) {
|
|||||||
.build(),
|
.build(),
|
||||||
)
|
)
|
||||||
.with_filter(filter.clone());
|
.with_filter(filter.clone());
|
||||||
handles.insert("performance", filter);
|
filters.insert("performance", filter);
|
||||||
layers.push(layer.boxed());
|
layers.push(layer.boxed());
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -170,7 +170,7 @@ pub fn configure_veilid_platform(platform_config: String) {
|
|||||||
if platform_config.logging.api.enabled {
|
if platform_config.logging.api.enabled {
|
||||||
let filter = veilid_core::VeilidLayerFilter::new(platform_config.logging.api.level, None);
|
let filter = veilid_core::VeilidLayerFilter::new(platform_config.logging.api.level, None);
|
||||||
let layer = veilid_core::ApiTracingLayer::get().with_filter(filter.clone());
|
let layer = veilid_core::ApiTracingLayer::get().with_filter(filter.clone());
|
||||||
handles.insert("api", filter);
|
filters.insert("api", filter);
|
||||||
layers.push(layer.boxed());
|
layers.push(layer.boxed());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user