Change info logs
This commit is contained in:
@@ -75,7 +75,6 @@ class CoreFacadeImpl with ExceptionHandler, InfraLogger implements CoreFacade {
|
||||
) {
|
||||
return exceptionHandler(
|
||||
() {
|
||||
loggy.info("changing config options: ${options.format()}");
|
||||
return singbox
|
||||
.changeConfigOptions(options)
|
||||
.mapLeft(CoreServiceFailure.invalidConfigOptions)
|
||||
@@ -93,8 +92,13 @@ class CoreFacadeImpl with ExceptionHandler, InfraLogger implements CoreFacade {
|
||||
return exceptionHandler(
|
||||
() {
|
||||
final configPath = filesEditor.configPath(fileName);
|
||||
final options = configOptions();
|
||||
loggy.info(
|
||||
"config options: ${options.format()}\nMemory Limit: ${!disableMemoryLimit}",
|
||||
);
|
||||
|
||||
return setup()
|
||||
.andThen(() => changeConfigOptions(configOptions()))
|
||||
.andThen(() => changeConfigOptions(options))
|
||||
.andThen(
|
||||
() => singbox
|
||||
.start(configPath, disableMemoryLimit)
|
||||
|
||||
@@ -48,9 +48,10 @@ class ConnectivityController extends _$ConnectivityController with AppLogger {
|
||||
Future<void> reconnect(String? profileId) async {
|
||||
if (state case AsyncData(:final value) when value == const Connected()) {
|
||||
if (profileId == null) {
|
||||
loggy.info("no active profile, disconnecting");
|
||||
return _disconnect();
|
||||
}
|
||||
loggy.debug("reconnecting, profile: [$profileId]");
|
||||
loggy.info("active profile changed, reconnecting");
|
||||
await _core
|
||||
.restart(profileId, ref.read(disableMemoryLimitProvider))
|
||||
.mapLeft((err) {
|
||||
|
||||
@@ -53,50 +53,66 @@ class ProfilesNotifier extends _$ProfilesNotifier with AppLogger {
|
||||
final activeProfile = await ref.read(activeProfileProvider.future);
|
||||
final markAsActive =
|
||||
activeProfile == null || ref.read(markNewProfileActiveProvider);
|
||||
final TaskEither<ProfileFailure, Unit> task;
|
||||
if (LinkParser.parse(rawInput) case (final link)?) {
|
||||
loggy.debug("adding profile, url: [${link.url}]");
|
||||
return ref
|
||||
task = ref
|
||||
.read(profilesRepositoryProvider)
|
||||
.addByUrl(link.url, markAsActive: markAsActive)
|
||||
.getOrElse((err) {
|
||||
loggy.warning("failed to add profile", err);
|
||||
throw err;
|
||||
}).run();
|
||||
.addByUrl(link.url, markAsActive: markAsActive);
|
||||
} else if (LinkParser.protocol(rawInput) case (final parsed)?) {
|
||||
loggy.debug("adding profile, content");
|
||||
return ref
|
||||
.read(profilesRepositoryProvider)
|
||||
.addByContent(
|
||||
task = ref.read(profilesRepositoryProvider).addByContent(
|
||||
parsed.content,
|
||||
name: parsed.name,
|
||||
markAsActive: markAsActive,
|
||||
)
|
||||
.getOrElse((err) {
|
||||
loggy.warning("failed to add profile", err);
|
||||
throw err;
|
||||
}).run();
|
||||
);
|
||||
} else {
|
||||
loggy.debug("invalid content");
|
||||
throw const ProfileInvalidUrlFailure();
|
||||
}
|
||||
return task.match(
|
||||
(err) {
|
||||
loggy.warning("failed to add profile", err);
|
||||
throw err;
|
||||
},
|
||||
(_) {
|
||||
loggy.info(
|
||||
"successfully added profile, mark as active? [$markAsActive]",
|
||||
);
|
||||
return unit;
|
||||
},
|
||||
).run();
|
||||
}
|
||||
|
||||
Future<Unit?> updateProfile(RemoteProfile profile) async {
|
||||
loggy.debug("updating profile");
|
||||
return ref
|
||||
.read(profilesRepositoryProvider)
|
||||
.update(profile)
|
||||
.getOrElse((l) => throw l)
|
||||
.run();
|
||||
return ref.read(profilesRepositoryProvider).update(profile).match(
|
||||
(err) {
|
||||
loggy.warning("failed to update profile", err);
|
||||
throw err;
|
||||
},
|
||||
(_) {
|
||||
loggy.info(
|
||||
'successfully updated profile, was active? [${profile.active}]',
|
||||
);
|
||||
return unit;
|
||||
},
|
||||
).run();
|
||||
}
|
||||
|
||||
Future<void> deleteProfile(Profile profile) async {
|
||||
loggy.debug('deleting profile: ${profile.name}');
|
||||
await _profilesRepo.delete(profile.id).mapLeft(
|
||||
await _profilesRepo.delete(profile.id).match(
|
||||
(err) {
|
||||
loggy.warning('failed to delete profile', err);
|
||||
throw err;
|
||||
},
|
||||
(_) {
|
||||
loggy.info(
|
||||
'successfully deleted profile, was active? [${profile.active}]',
|
||||
);
|
||||
return unit;
|
||||
},
|
||||
).run();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user