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