Skip to content

Commit

Permalink
Adjust dart config
Browse files Browse the repository at this point in the history
  • Loading branch information
jerel committed Aug 29, 2023
1 parent 06a1751 commit 66567f8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
8 changes: 4 additions & 4 deletions membrane/src/generators/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ impl Callable for Ffi {
} else {
String::from(", ") + self.fun.dart_inner_args
},
fine_logger = config.dart_config.fine_log_fn
fine_logger = config.dart_config.logger.fine_log_fn
)
.as_str();
self
Expand Down Expand Up @@ -350,7 +350,7 @@ impl Callable for Ffi {
error_de = self.fun.deserializer(self.fun.error_type, enum_tracer_registry, config),
class_name = self.fun.namespace.to_upper_camel_case(),
fn_name = self.fun.fn_name,
fine_logger = config.dart_config.fine_log_fn
fine_logger = config.dart_config.logger.fine_log_fn
)
} else if self.fun.is_stream {
format!(
Expand Down Expand Up @@ -383,7 +383,7 @@ impl Callable for Ffi {
// having all streams auto-disconnect after a pause in events is not desirable
"".to_string()
},
fine_logger = config.dart_config.fine_log_fn
fine_logger = config.dart_config.logger.fine_log_fn
)
} else {
format!(
Expand Down Expand Up @@ -422,7 +422,7 @@ impl Callable for Ffi {
// and by default we won't time out at all
"".to_string()
},
fine_logger = config.dart_config.fine_log_fn
fine_logger = config.dart_config.logger.fine_log_fn
)
}
.as_str();
Expand Down
8 changes: 4 additions & 4 deletions membrane/src/generators/loaders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ bool bindingsLoaded = false;
final bindings = _load();
"#,
lib = library,
logger_path = dart_config.logger_import_path,
logger = dart_config.logger,
info_logger = dart_config.info_log_fn,
fine_logger = dart_config.fine_log_fn,
logger_path = dart_config.logger.import_path,
logger = dart_config.logger.instance,
info_logger = dart_config.logger.info_log_fn,
fine_logger = dart_config.logger.fine_log_fn,
)
}

Expand Down
22 changes: 14 additions & 8 deletions membrane/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,24 @@ use std::{
};
use tracing::{debug, info, warn};

#[derive(Debug)]
#[derive(Debug, Default)]
pub struct DartConfig {
pub logger_import_path: &'static str,
pub logger: &'static str,
pub logger: DartLoggerConfig,
}

#[derive(Debug)]
pub struct DartLoggerConfig {
pub import_path: &'static str,
pub instance: &'static str,
pub info_log_fn: &'static str,
pub fine_log_fn: &'static str,
}

impl Default for DartConfig {
impl Default for DartLoggerConfig {
fn default() -> Self {
Self {
logger_import_path: "package:logging/logging.dart",
logger: "Logger('membrane')",
import_path: "package:logging/logging.dart",
instance: "Logger('membrane')",
info_log_fn: "info",
fine_log_fn: "fine",
}
Expand Down Expand Up @@ -567,7 +572,7 @@ impl<'a> Membrane {
/// Default:
///
/// DartConfig {
/// logger_import_path: "package:logging/logging.dart",
/// import_path: "package:logging/logging.dart",
/// logger: "Logger('membrane')",
/// info_log_fn: "info",
/// fine_log_fn: "fine",
Expand Down Expand Up @@ -978,10 +983,11 @@ class {class_name}Api {{
"#,
ns = &namespace,
class_name = &namespace.to_upper_camel_case(),
logger_path = self.dart_config.logger_import_path,
logger_path = self.dart_config.logger.import_path,
logger = self
.dart_config
.logger
.instance
.replace("')", &format!(".{}')", &namespace))
.replace("\")", &format!(".{}\")", &namespace)),
);
Expand Down

0 comments on commit 66567f8

Please sign in to comment.