Skip to content

Commit

Permalink
Redo logger structure
Browse files Browse the repository at this point in the history
  • Loading branch information
Craftplacer committed Nov 4, 2024
1 parent 759adc0 commit c7a69e6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
2 changes: 1 addition & 1 deletion packages/sane/lib/src/logger.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import 'package:logging/logging.dart';

final logger = Logger('sane.dart');
final logger = Logger('sane');
40 changes: 21 additions & 19 deletions packages/sane/lib/src/sane_dev.dart
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import 'dart:typed_data';

import 'package:logging/logging.dart';
import 'package:sane/sane.dart';
import 'package:sane/src/logger.dart';

final _logger = Logger('sane.sane_dev');

class SaneDev implements Sane {
@override
Future<void> cancel(SaneHandle handle) {
return Future.delayed(const Duration(seconds: 1), () {
logger.finest('sane_cancel()');
_logger.finest('sane_cancel()');
});
}

@override
Future<void> close(SaneHandle handle) {
return Future.delayed(const Duration(seconds: 1), () {
logger.finest('sane_close()');
_logger.finest('sane_close()');
});
}

Expand All @@ -26,7 +28,7 @@ class SaneDev implements Sane {
bool? value,
}) {
return Future.delayed(const Duration(seconds: 1), () {
logger.finest('sane_controlBoolOption()');
_logger.finest('sane_controlBoolOption()');
return SaneOptionResult(result: value ?? true, infos: []);
});
}
Expand All @@ -37,7 +39,7 @@ class SaneDev implements Sane {
required int index,
}) {
return Future.delayed(const Duration(seconds: 1), () {
logger.finest('sane_controlButtonOption()');
_logger.finest('sane_controlButtonOption()');
return SaneOptionResult(result: null, infos: []);
});
}
Expand All @@ -50,7 +52,7 @@ class SaneDev implements Sane {
double? value,
}) {
return Future.delayed(const Duration(seconds: 1), () {
logger.finest('sane_controlFixedOption()');
_logger.finest('sane_controlFixedOption()');
return SaneOptionResult(result: value ?? .1, infos: []);
});
}
Expand All @@ -63,7 +65,7 @@ class SaneDev implements Sane {
int? value,
}) {
return Future.delayed(const Duration(seconds: 1), () {
logger.finest('sane_controlIntOption()');
_logger.finest('sane_controlIntOption()');
return SaneOptionResult(result: value ?? 1, infos: []);
});
}
Expand All @@ -76,15 +78,15 @@ class SaneDev implements Sane {
String? value,
}) {
return Future.delayed(const Duration(seconds: 1), () {
logger.finest('sane_controlStringOption()');
_logger.finest('sane_controlStringOption()');
return SaneOptionResult(result: value ?? 'value', infos: []);
});
}

@override
Future<void> exit() {
return Future(() {
logger.finest('sane_exit()');
_logger.finest('sane_exit()');
});
}

Expand All @@ -93,7 +95,7 @@ class SaneDev implements Sane {
SaneHandle handle,
) {
return Future.delayed(const Duration(seconds: 1), () {
logger.finest('sane_getAllOptionDescriptors()');
_logger.finest('sane_getAllOptionDescriptors()');
return [
SaneOptionDescriptor(
index: 0,
Expand All @@ -115,7 +117,7 @@ class SaneDev implements Sane {
required bool localOnly,
}) {
return Future.delayed(const Duration(seconds: 1), () {
logger.finest('sane_getDevices()');
_logger.finest('sane_getDevices()');
return [
for (var i = 0; i < 3; i++)
SaneDevice(
Expand All @@ -134,7 +136,7 @@ class SaneDev implements Sane {
int index,
) {
return Future.delayed(const Duration(seconds: 1), () {
logger.finest('sane_getOptionDescriptor()');
_logger.finest('sane_getOptionDescriptor()');
return SaneOptionDescriptor(
index: index,
name: 'name',
Expand All @@ -152,7 +154,7 @@ class SaneDev implements Sane {
@override
Future<SaneParameters> getParameters(SaneHandle handle) {
return Future.delayed(const Duration(seconds: 1), () {
logger.finest('sane_getParameters()');
_logger.finest('sane_getParameters()');
return SaneParameters(
format: SaneFrameFormat.gray,
lastFrame: true,
Expand All @@ -169,46 +171,46 @@ class SaneDev implements Sane {
AuthCallback? authCallback,
}) {
return Future(() {
logger.finest('sane_init()');
_logger.finest('sane_init()');
return 1;
});
}

@override
Future<SaneHandle> open(String deviceName) {
return Future.delayed(const Duration(seconds: 1), () {
logger.finest('sane_open()');
_logger.finest('sane_open()');
return SaneHandle(deviceName: deviceName);
});
}

@override
Future<SaneHandle> openDevice(SaneDevice device) {
return Future.delayed(const Duration(seconds: 1), () {
logger.finest('sane_openDevice()');
_logger.finest('sane_openDevice()');
return SaneHandle(deviceName: device.name);
});
}

@override
Future<Uint8List> read(SaneHandle handle, int bufferSize) {
return Future.delayed(const Duration(seconds: 1), () {
logger.finest('sane_read()');
_logger.finest('sane_read()');
return Uint8List.fromList([]);
});
}

@override
Future<void> setIOMode(SaneHandle handle, SaneIOMode mode) {
return Future.delayed(const Duration(seconds: 1), () {
logger.finest('sane_setIOMode()');
_logger.finest('sane_setIOMode()');
});
}

@override
Future<void> start(SaneHandle handle) {
return Future.delayed(const Duration(seconds: 1), () {
logger.finest('sane_start()');
_logger.finest('sane_start()');
});
}
}

0 comments on commit c7a69e6

Please sign in to comment.