Use "standard" log level names.

This commit is contained in:
Dain Nilsson 2022-05-03 11:24:25 +02:00
parent 51a76f686d
commit 488b1189ad
No known key found for this signature in database
GPG Key ID: F04367096FBA95E8
16 changed files with 97 additions and 70 deletions

View File

@ -66,7 +66,7 @@ class LoggingPanel extends ConsumerWidget {
DropdownButton<Level>( DropdownButton<Level>(
value: ref.watch(logLevelProvider), value: ref.watch(logLevelProvider),
isDense: true, isDense: true,
items: [Level.WARNING, Level.INFO, Level.CONFIG, Level.FINE] items: Levels.LEVELS
.map((e) => DropdownMenuItem( .map((e) => DropdownMenuItem(
value: e, value: e,
child: Text(e.name.toUpperCase()), child: Text(e.name.toUpperCase()),
@ -74,7 +74,7 @@ class LoggingPanel extends ConsumerWidget {
.toList(), .toList(),
onChanged: (level) { onChanged: (level) {
ref.read(logLevelProvider.notifier).setLogLevel(level!); ref.read(logLevelProvider.notifier).setLogLevel(level!);
_log.config('Log level set to $level'); _log.debug('Log level set to $level');
showMessage(context, 'Log level set to $level'); showMessage(context, 'Log level set to $level');
}, },
), ),

View File

@ -3,6 +3,7 @@ import 'dart:convert';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:logging/logging.dart'; import 'package:logging/logging.dart';
import 'package:yubico_authenticator/android/oath/command_providers.dart'; import 'package:yubico_authenticator/android/oath/command_providers.dart';
import 'package:yubico_authenticator/app/logging.dart';
import '../app/models.dart'; import '../app/models.dart';
import '../core/models.dart'; import '../core/models.dart';
@ -22,7 +23,7 @@ class _YubikeyProvider extends StateNotifier<YubiKeyData?> {
void setFromString(String input) { void setFromString(String input) {
try { try {
if (input.isEmpty) { if (input.isEmpty) {
_log.config('Yubikey was detached.'); _log.debug('Yubikey was detached.');
state = null; state = null;
// reset other providers when YubiKey is removed // reset other providers when YubiKey is removed
@ -46,7 +47,7 @@ class _YubikeyProvider extends StateNotifier<YubiKeyData?> {
deviceInfo); deviceInfo);
state = YubiKeyData(deviceNode, name, deviceInfo); state = YubiKeyData(deviceNode, name, deviceInfo);
} on Exception catch (e) { } on Exception catch (e) {
_log.config('Invalid data for yubikey: $input. $e'); _log.debug('Invalid data for yubikey: $input. $e');
state = null; state = null;
} }
} }

View File

@ -7,6 +7,7 @@ import 'package:flutter/services.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:logging/logging.dart'; import 'package:logging/logging.dart';
import 'package:yubico_authenticator/android/api/impl.dart'; import 'package:yubico_authenticator/android/api/impl.dart';
import 'package:yubico_authenticator/app/logging.dart';
import 'package:yubico_authenticator/app/models.dart'; import 'package:yubico_authenticator/app/models.dart';
import 'package:yubico_authenticator/app/state.dart'; import 'package:yubico_authenticator/app/state.dart';
import 'package:yubico_authenticator/core/models.dart'; import 'package:yubico_authenticator/core/models.dart';
@ -45,7 +46,7 @@ class _AndroidOathStateNotifier extends OathStateNotifier {
.copyWith(locked: false, remembered: false, hasKey: false)); .copyWith(locked: false, remembered: false, hasKey: false));
_ref.refresh(androidStateProvider); _ref.refresh(androidStateProvider);
} catch (e) { } catch (e) {
_log.config('Calling reset failed with exception: $e'); _log.debug('Calling reset failed with exception: $e');
} }
} }
@ -59,7 +60,7 @@ class _AndroidOathStateNotifier extends OathStateNotifier {
final remembered = unlockResponse.isRemembered == true; final remembered = unlockResponse.isRemembered == true;
if (unlocked) { if (unlocked) {
_log.config('applet unlocked'); _log.debug('applet unlocked');
setData(state.value!.copyWith( setData(state.value!.copyWith(
locked: false, locked: false,
remembered: remembered, remembered: remembered,
@ -67,7 +68,7 @@ class _AndroidOathStateNotifier extends OathStateNotifier {
} }
return Pair(unlocked, remembered); return Pair(unlocked, remembered);
} on PlatformException catch (e) { } on PlatformException catch (e) {
_log.config('Calling unlock failed with exception: $e'); _log.debug('Calling unlock failed with exception: $e');
return Pair(false, false); return Pair(false, false);
} }
} }
@ -79,7 +80,7 @@ class _AndroidOathStateNotifier extends OathStateNotifier {
setData(state.value!.copyWith(hasKey: true)); setData(state.value!.copyWith(hasKey: true));
return true; return true;
} on PlatformException catch (e) { } on PlatformException catch (e) {
_log.config('Calling set password failed with exception: $e'); _log.debug('Calling set password failed with exception: $e');
return false; return false;
} }
} }
@ -91,7 +92,7 @@ class _AndroidOathStateNotifier extends OathStateNotifier {
setData(state.value!.copyWith(hasKey: false, locked: false)); setData(state.value!.copyWith(hasKey: false, locked: false));
return true; return true;
} on PlatformException catch (e) { } on PlatformException catch (e) {
_log.config('Calling unset password failed with exception: $e'); _log.debug('Calling unset password failed with exception: $e');
return false; return false;
} }
} }
@ -102,7 +103,7 @@ class _AndroidOathStateNotifier extends OathStateNotifier {
await _api.forgetPassword(); await _api.forgetPassword();
setData(state.value!.copyWith(remembered: false)); setData(state.value!.copyWith(remembered: false));
} on PlatformException catch (e) { } on PlatformException catch (e) {
_log.config('Calling forgetPassword failed with exception: $e'); _log.debug('Calling forgetPassword failed with exception: $e');
} }
} }
} }
@ -162,7 +163,7 @@ class _AndroidCredentialListNotifier extends OathCredentialListNotifier {
var resultJson = await _api.calculate(credential.id); var resultJson = await _api.calculate(credential.id);
var result = jsonDecode(resultJson); var result = jsonDecode(resultJson);
code = OathCode.fromJson(result); code = OathCode.fromJson(result);
_log.config('Calculate', jsonEncode(code)); _log.debug('Calculate', jsonEncode(code));
if (update && mounted) { if (update && mounted) {
final creds = state!.toList(); final creds = state!.toList();
final i = creds.indexWhere((e) => e.credential.id == credential.id); final i = creds.indexWhere((e) => e.credential.id == credential.id);
@ -219,7 +220,7 @@ class _AndroidCredentialListNotifier extends OathCredentialListNotifier {
return renamedCredential; return renamedCredential;
} on PlatformException catch (e) { } on PlatformException catch (e) {
_log.config('Failed to execute renameOathCredential: ${e.message}'); _log.debug('Failed to execute renameOathCredential: ${e.message}');
} }
return credential; return credential;
@ -234,13 +235,13 @@ class _AndroidCredentialListNotifier extends OathCredentialListNotifier {
state = state!.toList()..removeWhere((e) => e.credential == credential); state = state!.toList()..removeWhere((e) => e.credential == credential);
} }
} catch (e) { } catch (e) {
_log.config('Call to delete credential failed: $e'); _log.debug('Call to delete credential failed: $e');
} }
} }
refresh() async { refresh() async {
if (_currentDevice == null) return; if (_currentDevice == null) return;
_log.config('refreshing credentials...'); _log.debug('refreshing credentials...');
final pairs = []; final pairs = [];
@ -269,7 +270,7 @@ class _AndroidCredentialListNotifier extends OathCredentialListNotifier {
_scheduleRefresh(); _scheduleRefresh();
} }
} catch (e) { } catch (e) {
_log.config('Failure refreshing codes: $e'); _log.debug('Failure refreshing codes: $e');
} }
} }

View File

@ -2,15 +2,38 @@ import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:logging/logging.dart'; import 'package:logging/logging.dart';
class Levels {
/// Key for tracing information ([value] = 500).
static const Level TRAFFIC = Level('TRAFFIC', 500);
/// Key for static configuration messages ([value] = 700).
static const Level DEBUG = Level('DEBUG', 700);
/// Key for informational messages ([value] = 800).
static const Level INFO = Level.INFO;
/// Key for potential problems ([value] = 900).
static const Level WARNING = Level.WARNING;
/// Key for serious failures ([value] = 1000).
static const Level ERROR = Level('ERROR', 1000);
static const List<Level> LEVELS = [
TRAFFIC,
DEBUG,
INFO,
WARNING,
ERROR,
];
}
extension LoggerExt on Logger { extension LoggerExt on Logger {
void critical(Object? message, [Object? error, StackTrace? stackTrace]) =>
shout(message, error, stackTrace);
void error(Object? message, [Object? error, StackTrace? stackTrace]) => void error(Object? message, [Object? error, StackTrace? stackTrace]) =>
severe(message, error, stackTrace); log(Levels.ERROR, message, error, stackTrace);
void debug(Object? message, [Object? error, StackTrace? stackTrace]) => void debug(Object? message, [Object? error, StackTrace? stackTrace]) =>
config(message, error, stackTrace); log(Levels.DEBUG, message, error, stackTrace);
void traffic(Object? message, [Object? error, StackTrace? stackTrace]) => void traffic(Object? message, [Object? error, StackTrace? stackTrace]) =>
fine(message, error, stackTrace); log(Levels.TRAFFIC, message, error, stackTrace);
} }
final logLevelProvider = final logLevelProvider =

View File

@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:logging/logging.dart'; import 'package:logging/logging.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
import 'package:yubico_authenticator/app/logging.dart';
import '../core/state.dart'; import '../core/state.dart';
import 'models.dart'; import 'models.dart';
@ -28,7 +29,7 @@ class ThemeModeNotifier extends StateNotifier<ThemeMode> {
ThemeModeNotifier(this._prefs) : super(_fromName(_prefs.getString(_key))); ThemeModeNotifier(this._prefs) : super(_fromName(_prefs.getString(_key)));
void setThemeMode(ThemeMode mode) { void setThemeMode(ThemeMode mode) {
_log.config('Set theme to $mode'); _log.debug('Set theme to $mode');
state = mode; state = mode;
_prefs.setString(_key, mode.name); _prefs.setString(_key, mode.name);
} }

View File

@ -3,6 +3,7 @@ import 'dart:convert';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:logging/logging.dart'; import 'package:logging/logging.dart';
import 'package:yubico_authenticator/app/logging.dart';
import '../app/models.dart'; import '../app/models.dart';
import '../app/state.dart'; import '../app/state.dart';
@ -36,7 +37,7 @@ class UsbDeviceNotifier extends StateNotifier<List<UsbYubiKeyNode>> {
UsbDeviceNotifier(this._rpc) : super([]); UsbDeviceNotifier(this._rpc) : super([]);
void refresh() { void refresh() {
_log.config('Refreshing all USB devics'); _log.debug('Refreshing all USB devics');
_usbState = -1; _usbState = -1;
_pollDevices(); _pollDevices();
} }
@ -106,7 +107,7 @@ class UsbDeviceNotifier extends StateNotifier<List<UsbYubiKeyNode>> {
} }
} }
} on RpcError catch (e) { } on RpcError catch (e) {
_log.severe('Error polling USB', jsonEncode(e)); _log.error('Error polling USB', jsonEncode(e));
} }
if (mounted) { if (mounted) {
@ -163,7 +164,7 @@ class NfcDeviceNotifier extends StateNotifier<List<NfcReaderNode>> {
.toList(); .toList();
} }
} on RpcError catch (e) { } on RpcError catch (e) {
_log.severe('Error polling NFC', jsonEncode(e)); _log.error('Error polling NFC', jsonEncode(e));
} }
if (mounted) { if (mounted) {
@ -249,7 +250,7 @@ class CurrentDeviceDataNotifier extends StateNotifier<YubiKeyData?> {
_pollTimer?.cancel(); _pollTimer?.cancel();
final node = _deviceNode!; final node = _deviceNode!;
try { try {
_log.config('Polling for USB device changes...'); _log.debug('Polling for USB device changes...');
var result = await _rpc.command('get', node.path.segments); var result = await _rpc.command('get', node.path.segments);
if (mounted) { if (mounted) {
if (result['data']['present']) { if (result['data']['present']) {
@ -260,7 +261,7 @@ class CurrentDeviceDataNotifier extends StateNotifier<YubiKeyData?> {
} }
} }
} on RpcError catch (e) { } on RpcError catch (e) {
_log.severe('Error polling NFC', jsonEncode(e)); _log.error('Error polling NFC', jsonEncode(e));
} }
if (mounted) { if (mounted) {
_pollTimer = Timer( _pollTimer = Timer(

View File

@ -4,6 +4,7 @@ import 'dart:io';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:logging/logging.dart'; import 'package:logging/logging.dart';
import 'package:yubico_authenticator/app/logging.dart';
import '../../app/models.dart'; import '../../app/models.dart';
import '../../fido/models.dart'; import '../../fido/models.dart';
@ -66,7 +67,7 @@ class _DesktopFidoStateNotifier extends FidoStateNotifier {
Future<void> refresh() => updateState(() async { Future<void> refresh() => updateState(() async {
final result = await _session.command('get'); final result = await _session.command('get');
_log.config('application status', jsonEncode(result)); _log.debug('application status', jsonEncode(result));
return FidoState.fromJson(result['data']); return FidoState.fromJson(result['data']);
}); });

View File

@ -6,6 +6,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:logging/logging.dart'; import 'package:logging/logging.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
import 'package:window_manager/window_manager.dart'; import 'package:window_manager/window_manager.dart';
import 'package:yubico_authenticator/app/logging.dart';
import '../app/app.dart'; import '../app/app.dart';
import '../app/views/main_page.dart'; import '../app/views/main_page.dart';
@ -119,12 +120,12 @@ void _initLogging(List<String> argv) {
if (logLevelIndex != -1) { if (logLevelIndex != -1) {
try { try {
final levelName = argv[logLevelIndex + 1]; final levelName = argv[logLevelIndex + 1];
Level level = Level.LEVELS Level level = Levels.LEVELS
.firstWhere((level) => level.name == levelName.toUpperCase()); .firstWhere((level) => level.name == levelName.toUpperCase());
Logger.root.level = level; Logger.root.level = level;
_log.info('Log level initialized from command line argument'); _log.info('Log level initialized from command line argument');
} catch (error) { } catch (error) {
_log.severe('Failed to set log level', error); _log.error('Failed to set log level', error);
} }
} }

View File

@ -2,6 +2,7 @@ import 'dart:async';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:logging/logging.dart'; import 'package:logging/logging.dart';
import 'package:yubico_authenticator/app/logging.dart';
import 'package:yubico_authenticator/management/models.dart'; import 'package:yubico_authenticator/management/models.dart';
import '../../app/models.dart'; import '../../app/models.dart';
@ -56,7 +57,7 @@ class _DesktopManagementStateNotifier extends ManagementStateNotifier {
try { try {
await _session.command('get', target: path); await _session.command('get', target: path);
_subpath = path; _subpath = path;
_log.config('Using transport $iface for management'); _log.debug('Using transport $iface for management');
return info; return info;
} catch (e) { } catch (e) {
_log.warning('Failed connecting to management via $iface'); _log.warning('Failed connecting to management via $iface');

View File

@ -4,6 +4,7 @@ import 'dart:math';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:logging/logging.dart'; import 'package:logging/logging.dart';
import 'package:yubico_authenticator/app/logging.dart';
import 'package:yubico_authenticator/app/views/user_interaction.dart'; import 'package:yubico_authenticator/app/views/user_interaction.dart';
import '../../app/models.dart'; import '../../app/models.dart';
@ -72,7 +73,7 @@ class _DesktopOathStateNotifier extends OathStateNotifier {
refresh() => updateState(() async { refresh() => updateState(() async {
final result = await _session.command('get'); final result = await _session.command('get');
_log.config('application status', jsonEncode(result)); _log.debug('application status', jsonEncode(result));
var oathState = OathState.fromJson(result['data']); var oathState = OathState.fromJson(result['data']);
final key = _ref.read(_oathLockKeyProvider(_session.devicePath)); final key = _ref.read(_oathLockKeyProvider(_session.devicePath));
if (oathState.locked && key != null) { if (oathState.locked && key != null) {
@ -107,7 +108,7 @@ class _DesktopOathStateNotifier extends OathStateNotifier {
final bool valid = validate['valid']; final bool valid = validate['valid'];
final bool remembered = validate['remembered']; final bool remembered = validate['remembered'];
if (valid) { if (valid) {
_log.config('applet unlocked'); _log.debug('applet unlocked');
_ref.read(_oathLockKeyProvider(_session.devicePath).notifier).setKey(key); _ref.read(_oathLockKeyProvider(_session.devicePath).notifier).setKey(key);
setData(state.value!.copyWith( setData(state.value!.copyWith(
locked: false, locked: false,
@ -148,7 +149,7 @@ class _DesktopOathStateNotifier extends OathStateNotifier {
await _session.command('set_key', params: {'key': key}); await _session.command('set_key', params: {'key': key});
_ref.read(_oathLockKeyProvider(_session.devicePath).notifier).setKey(key); _ref.read(_oathLockKeyProvider(_session.devicePath).notifier).setKey(key);
} }
_log.config('OATH key set'); _log.debug('OATH key set');
if (!oathState.hasKey) { if (!oathState.hasKey) {
setData(oathState.copyWith(hasKey: true)); setData(oathState.copyWith(hasKey: true));
@ -231,7 +232,7 @@ class _DesktopCredentialListNotifier extends OathCredentialListNotifier {
@override @override
void dispose() { void dispose() {
_log.config('OATH notifier discarded'); _log.debug('OATH notifier discarded');
_timer?.cancel(); _timer?.cancel();
super.dispose(); super.dispose();
} }
@ -269,7 +270,7 @@ class _DesktopCredentialListNotifier extends OathCredentialListNotifier {
target: ['accounts', credential.id], signal: signaler); target: ['accounts', credential.id], signal: signaler);
code = OathCode.fromJson(result); code = OathCode.fromJson(result);
} }
_log.config('Calculate', jsonEncode(code)); _log.debug('Calculate', jsonEncode(code));
if (update && mounted) { if (update && mounted) {
final creds = state!.toList(); final creds = state!.toList();
final i = creds.indexWhere((e) => e.credential.id == credential.id); final i = creds.indexWhere((e) => e.credential.id == credential.id);
@ -333,9 +334,9 @@ class _DesktopCredentialListNotifier extends OathCredentialListNotifier {
refresh() async { refresh() async {
if (_locked) return; if (_locked) return;
_log.config('refreshing credentials...'); _log.debug('refreshing credentials...');
var result = await _session.command('calculate_all', target: ['accounts']); var result = await _session.command('calculate_all', target: ['accounts']);
_log.config('Entries', jsonEncode(result)); _log.debug('Entries', jsonEncode(result));
final pairs = []; final pairs = [];
for (var e in result['entries']) { for (var e in result['entries']) {
@ -368,7 +369,7 @@ class _DesktopCredentialListNotifier extends OathCredentialListNotifier {
_timer?.cancel(); _timer?.cancel();
if (_locked) return; if (_locked) return;
if (state == null) { if (state == null) {
_log.config('No OATH state, refresh immediately'); _log.debug('No OATH state, refresh immediately');
refresh(); refresh();
} else if (mounted) { } else if (mounted) {
final expirations = (state ?? []) final expirations = (state ?? [])
@ -379,16 +380,16 @@ class _DesktopCredentialListNotifier extends OathCredentialListNotifier {
.whereType<OathCode>() .whereType<OathCode>()
.map((e) => e.validTo); .map((e) => e.validTo);
if (expirations.isEmpty) { if (expirations.isEmpty) {
_log.config('No expirations, no refresh'); _log.debug('No expirations, no refresh');
_timer = null; _timer = null;
} else { } else {
final earliest = expirations.reduce(min) * 1000; final earliest = expirations.reduce(min) * 1000;
final now = DateTime.now().millisecondsSinceEpoch; final now = DateTime.now().millisecondsSinceEpoch;
if (earliest < now) { if (earliest < now) {
_log.config('Already expired, refresh immediately'); _log.debug('Already expired, refresh immediately');
refresh(); refresh();
} else { } else {
_log.config('Schedule refresh in ${earliest - now}ms'); _log.debug('Schedule refresh in ${earliest - now}ms');
_timer = Timer(Duration(milliseconds: earliest - now), refresh); _timer = Timer(Duration(milliseconds: earliest - now), refresh);
} }
} }

View File

@ -64,7 +64,7 @@ class _RpcConnection {
try { try {
return RpcResponse.fromJson(jsonDecode(event)); return RpcResponse.fromJson(jsonDecode(event));
} catch (e) { } catch (e) {
_log.severe('Response was not valid JSON', event); _log.error('Response was not valid JSON', event);
return RpcResponse.error('invalid-response', e.toString(), {}); return RpcResponse.error('invalid-response', e.toString(), {});
} }
})); }));
@ -105,7 +105,7 @@ class RpcSession {
Future<void> initialize() async { Future<void> initialize() async {
final process = await Process.start(executable, []); final process = await Process.start(executable, []);
_log.config('RPC process started'); _log.debug('RPC process started');
process.stderr process.stderr
.transform(const Utf8Decoder()) .transform(const Utf8Decoder())
.transform(const LineSplitter()) .transform(const LineSplitter())
@ -133,7 +133,7 @@ class RpcSession {
// Bind to random port // Bind to random port
final server = await ServerSocket.bind(InternetAddress.loopbackIPv4, 0); final server = await ServerSocket.bind(InternetAddress.loopbackIPv4, 0);
final port = server.port; final port = server.port;
_log.config('Listening for RPC connection on $port'); _log.debug('Listening for RPC connection on $port');
// Launch the elevated process // Launch the elevated process
final process = final process =
@ -153,12 +153,12 @@ class RpcSession {
_log.warning('Failed to elevate RPC process', error); _log.warning('Failed to elevate RPC process', error);
return false; return false;
} }
_log.config('Elevated RPC process started'); _log.debug('Elevated RPC process started');
// Accept only a single connection // Accept only a single connection
final client = await server.first; final client = await server.first;
await server.close(); await server.close();
_log.config('Client connected: $client'); _log.debug('Client connected: $client');
// Stop the old subprocess. // Stop the old subprocess.
try { try {
@ -174,7 +174,7 @@ class RpcSession {
// The nonce needs to be received first. // The nonce needs to be received first.
if (!authenticated) { if (!authenticated) {
if (nonce == line) { if (nonce == line) {
_log.config('Client authenticated with correct nonce'); _log.debug('Client authenticated with correct nonce');
authenticated = true; authenticated = true;
completer.complete(); completer.complete();
return ''; return '';
@ -213,22 +213,13 @@ class RpcSession {
return request.completer.future; return request.completer.future;
} }
setLogLevel(Level level) { void setLogLevel(Level level) async {
String pyLevel; final name = Levels.LEVELS
if (level.value <= Level.FINE.value) { .firstWhere((e) => level.value <= e.value, orElse: () => Level.OFF)
pyLevel = 'traffic'; .name
} else if (level.value <= Level.CONFIG.value) { .toLowerCase();
pyLevel = 'debug';
} else if (level.value <= Level.INFO.value) { await command('logging', [], params: {'level': name});
pyLevel = 'info';
} else if (level.value <= Level.WARNING.value) {
pyLevel = 'warning';
} else if (level.value <= Level.SEVERE.value) {
pyLevel = 'error';
} else {
pyLevel = 'critical';
}
command('logging', [], params: {'level': pyLevel});
} }
void _send(Map data) { void _send(Map data) {

View File

@ -5,6 +5,7 @@ import 'package:logging/logging.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
import 'package:window_manager/window_manager.dart'; import 'package:window_manager/window_manager.dart';
import 'package:yubico_authenticator/app/logging.dart';
import '../app/state.dart'; import '../app/state.dart';
import '../core/state.dart'; import '../core/state.dart';
@ -74,7 +75,7 @@ class _WindowStateNotifier extends StateNotifier<WindowState>
@override @override
set state(WindowState value) { set state(WindowState value) {
_log.config('Window state changed: $value'); _log.debug('Window state changed: $value');
super.state = value; super.state = value;
} }
@ -104,7 +105,7 @@ class _WindowStateNotifier extends StateNotifier<WindowState>
_idleTimer?.cancel(); _idleTimer?.cancel();
break; break;
default: default:
_log.fine('Window event ignored: $eventName'); _log.traffic('Window event ignored: $eventName');
} }
} }
} }

View File

@ -3,6 +3,7 @@ import 'dart:async';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:logging/logging.dart'; import 'package:logging/logging.dart';
import 'package:yubico_authenticator/app/logging.dart';
import '../../app/message.dart'; import '../../app/message.dart';
import '../../widgets/responsive_dialog.dart'; import '../../widgets/responsive_dialog.dart';
@ -83,12 +84,12 @@ class _AddFingerprintDialogState extends ConsumerState<AddFingerprintDialog>
// This needs a short delay to ensure the field is enabled first // This needs a short delay to ensure the field is enabled first
Timer(const Duration(milliseconds: 100), _nameFocus.requestFocus); Timer(const Duration(milliseconds: 100), _nameFocus.requestFocus);
}, error: (code) { }, error: (code) {
_log.config('Fingerprint capture error (code: $code)'); _log.debug('Fingerprint capture error (code: $code)');
_color = _animateColor(Colors.redAccent); _color = _animateColor(Colors.redAccent);
}); });
}); });
}, onError: (error, stacktrace) { }, onError: (error, stacktrace) {
_log.severe('Error adding fingerprint', error, stacktrace); _log.error('Error adding fingerprint', error, stacktrace);
Navigator.of(context).pop(); Navigator.of(context).pop();
showMessage(context, 'Error adding fingerprint'); showMessage(context, 'Error adding fingerprint');
}); });

View File

@ -3,6 +3,7 @@ import 'dart:async';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:logging/logging.dart'; import 'package:logging/logging.dart';
import 'package:yubico_authenticator/app/logging.dart';
import '../../app/message.dart'; import '../../app/message.dart';
import '../../core/models.dart'; import '../../core/models.dart';
@ -93,7 +94,7 @@ class _ResetDialogState extends ConsumerState<ResetDialog> {
Navigator.of(context).pop(); Navigator.of(context).pop();
showMessage(context, 'FIDO application reset'); showMessage(context, 'FIDO application reset');
}, onError: (e) { }, onError: (e) {
_log.severe('Error performing FIDO reset', e); _log.error('Error performing FIDO reset', e);
Navigator.of(context).pop(); Navigator.of(context).pop();
showMessage(context, 'Error performing reset'); showMessage(context, 'Error performing reset');
}); });

View File

@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:logging/logging.dart'; import 'package:logging/logging.dart';
import 'package:yubico_authenticator/app/logging.dart';
import '../../app/message.dart'; import '../../app/message.dart';
import '../../app/models.dart'; import '../../app/models.dart';
@ -383,7 +384,7 @@ class _OathAddAccountPageState extends ConsumerState<OathAddAccountPage> {
Navigator.of(context).pop(); Navigator.of(context).pop();
showMessage(context, 'Account added'); showMessage(context, 'Account added');
} catch (e) { } catch (e) {
_log.severe('Failed to add account', e); _log.error('Failed to add account', e);
showMessage(context, 'Failed adding account'); showMessage(context, 'Failed adding account');
} }
} else { } else {

View File

@ -1,6 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:logging/logging.dart'; import 'package:logging/logging.dart';
import 'package:yubico_authenticator/app/logging.dart';
import 'app/state.dart'; import 'app/state.dart';
import 'widgets/responsive_dialog.dart'; import 'widgets/responsive_dialog.dart';
@ -30,7 +31,7 @@ class SettingsPage extends ConsumerWidget {
.toList(), .toList(),
onChanged: (mode) { onChanged: (mode) {
ref.read(themeModeProvider.notifier).setThemeMode(mode!); ref.read(themeModeProvider.notifier).setThemeMode(mode!);
_log.config('Set theme mode to $mode'); _log.debug('Set theme mode to $mode');
}, },
), ),
], ],