feat(web,server)!: runtime log level (#5672)

* feat: change log level at runtime

* chore: open api

* chore: prefer env over runtime

* chore: remove default env value
This commit is contained in:
Jason Rasmussen 2023-12-14 11:55:40 -05:00 committed by GitHub
parent f2270ad757
commit 9768931275
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
61 changed files with 771 additions and 117 deletions

97
mobile/openapi/lib/model/log_level.dart generated Normal file
View file

@ -0,0 +1,97 @@
//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
// @dart=2.12
// ignore_for_file: unused_element, unused_import
// ignore_for_file: always_put_required_named_parameters_first
// ignore_for_file: constant_identifier_names
// ignore_for_file: lines_longer_than_80_chars
part of openapi.api;
class LogLevel {
/// Instantiate a new enum with the provided [value].
const LogLevel._(this.value);
/// The underlying value of this enum member.
final String value;
@override
String toString() => value;
String toJson() => value;
static const verbose = LogLevel._(r'verbose');
static const debug = LogLevel._(r'debug');
static const log = LogLevel._(r'log');
static const warn = LogLevel._(r'warn');
static const error = LogLevel._(r'error');
static const fatal = LogLevel._(r'fatal');
/// List of all possible values in this [enum][LogLevel].
static const values = <LogLevel>[
verbose,
debug,
log,
warn,
error,
fatal,
];
static LogLevel? fromJson(dynamic value) => LogLevelTypeTransformer().decode(value);
static List<LogLevel>? listFromJson(dynamic json, {bool growable = false,}) {
final result = <LogLevel>[];
if (json is List && json.isNotEmpty) {
for (final row in json) {
final value = LogLevel.fromJson(row);
if (value != null) {
result.add(value);
}
}
}
return result.toList(growable: growable);
}
}
/// Transformation class that can [encode] an instance of [LogLevel] to String,
/// and [decode] dynamic data back to [LogLevel].
class LogLevelTypeTransformer {
factory LogLevelTypeTransformer() => _instance ??= const LogLevelTypeTransformer._();
const LogLevelTypeTransformer._();
String encode(LogLevel data) => data.value;
/// Decodes a [dynamic value][data] to a LogLevel.
///
/// If [allowNull] is true and the [dynamic value][data] cannot be decoded successfully,
/// then null is returned. However, if [allowNull] is false and the [dynamic value][data]
/// cannot be decoded successfully, then an [UnimplementedError] is thrown.
///
/// The [allowNull] is very handy when an API changes and a new enum value is added or removed,
/// and users are still using an old app with the old code.
LogLevel? decode(dynamic data, {bool allowNull = true}) {
if (data != null) {
switch (data) {
case r'verbose': return LogLevel.verbose;
case r'debug': return LogLevel.debug;
case r'log': return LogLevel.log;
case r'warn': return LogLevel.warn;
case r'error': return LogLevel.error;
case r'fatal': return LogLevel.fatal;
default:
if (!allowNull) {
throw ArgumentError('Unknown enum value to decode: $data');
}
}
}
return null;
}
/// Singleton [LogLevelTypeTransformer] instance.
static LogLevelTypeTransformer? _instance;
}

View file

@ -16,6 +16,7 @@ class SystemConfigDto {
required this.ffmpeg,
required this.job,
required this.library_,
required this.logging,
required this.machineLearning,
required this.map,
required this.newVersionCheck,
@ -34,6 +35,8 @@ class SystemConfigDto {
SystemConfigLibraryDto library_;
SystemConfigLoggingDto logging;
SystemConfigMachineLearningDto machineLearning;
SystemConfigMapDto map;
@ -59,6 +62,7 @@ class SystemConfigDto {
other.ffmpeg == ffmpeg &&
other.job == job &&
other.library_ == library_ &&
other.logging == logging &&
other.machineLearning == machineLearning &&
other.map == map &&
other.newVersionCheck == newVersionCheck &&
@ -76,6 +80,7 @@ class SystemConfigDto {
(ffmpeg.hashCode) +
(job.hashCode) +
(library_.hashCode) +
(logging.hashCode) +
(machineLearning.hashCode) +
(map.hashCode) +
(newVersionCheck.hashCode) +
@ -88,13 +93,14 @@ class SystemConfigDto {
(trash.hashCode);
@override
String toString() => 'SystemConfigDto[ffmpeg=$ffmpeg, job=$job, library_=$library_, machineLearning=$machineLearning, map=$map, newVersionCheck=$newVersionCheck, oauth=$oauth, passwordLogin=$passwordLogin, reverseGeocoding=$reverseGeocoding, storageTemplate=$storageTemplate, theme=$theme, thumbnail=$thumbnail, trash=$trash]';
String toString() => 'SystemConfigDto[ffmpeg=$ffmpeg, job=$job, library_=$library_, logging=$logging, machineLearning=$machineLearning, map=$map, newVersionCheck=$newVersionCheck, oauth=$oauth, passwordLogin=$passwordLogin, reverseGeocoding=$reverseGeocoding, storageTemplate=$storageTemplate, theme=$theme, thumbnail=$thumbnail, trash=$trash]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
json[r'ffmpeg'] = this.ffmpeg;
json[r'job'] = this.job;
json[r'library'] = this.library_;
json[r'logging'] = this.logging;
json[r'machineLearning'] = this.machineLearning;
json[r'map'] = this.map;
json[r'newVersionCheck'] = this.newVersionCheck;
@ -119,6 +125,7 @@ class SystemConfigDto {
ffmpeg: SystemConfigFFmpegDto.fromJson(json[r'ffmpeg'])!,
job: SystemConfigJobDto.fromJson(json[r'job'])!,
library_: SystemConfigLibraryDto.fromJson(json[r'library'])!,
logging: SystemConfigLoggingDto.fromJson(json[r'logging'])!,
machineLearning: SystemConfigMachineLearningDto.fromJson(json[r'machineLearning'])!,
map: SystemConfigMapDto.fromJson(json[r'map'])!,
newVersionCheck: SystemConfigNewVersionCheckDto.fromJson(json[r'newVersionCheck'])!,
@ -179,6 +186,7 @@ class SystemConfigDto {
'ffmpeg',
'job',
'library',
'logging',
'machineLearning',
'map',
'newVersionCheck',

View file

@ -0,0 +1,106 @@
//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
// @dart=2.12
// ignore_for_file: unused_element, unused_import
// ignore_for_file: always_put_required_named_parameters_first
// ignore_for_file: constant_identifier_names
// ignore_for_file: lines_longer_than_80_chars
part of openapi.api;
class SystemConfigLoggingDto {
/// Returns a new [SystemConfigLoggingDto] instance.
SystemConfigLoggingDto({
required this.enabled,
required this.level,
});
bool enabled;
LogLevel level;
@override
bool operator ==(Object other) => identical(this, other) || other is SystemConfigLoggingDto &&
other.enabled == enabled &&
other.level == level;
@override
int get hashCode =>
// ignore: unnecessary_parenthesis
(enabled.hashCode) +
(level.hashCode);
@override
String toString() => 'SystemConfigLoggingDto[enabled=$enabled, level=$level]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
json[r'enabled'] = this.enabled;
json[r'level'] = this.level;
return json;
}
/// Returns a new [SystemConfigLoggingDto] instance and imports its values from
/// [value] if it's a [Map], null otherwise.
// ignore: prefer_constructors_over_static_methods
static SystemConfigLoggingDto? fromJson(dynamic value) {
if (value is Map) {
final json = value.cast<String, dynamic>();
return SystemConfigLoggingDto(
enabled: mapValueOfType<bool>(json, r'enabled')!,
level: LogLevel.fromJson(json[r'level'])!,
);
}
return null;
}
static List<SystemConfigLoggingDto> listFromJson(dynamic json, {bool growable = false,}) {
final result = <SystemConfigLoggingDto>[];
if (json is List && json.isNotEmpty) {
for (final row in json) {
final value = SystemConfigLoggingDto.fromJson(row);
if (value != null) {
result.add(value);
}
}
}
return result.toList(growable: growable);
}
static Map<String, SystemConfigLoggingDto> mapFromJson(dynamic json) {
final map = <String, SystemConfigLoggingDto>{};
if (json is Map && json.isNotEmpty) {
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
for (final entry in json.entries) {
final value = SystemConfigLoggingDto.fromJson(entry.value);
if (value != null) {
map[entry.key] = value;
}
}
}
return map;
}
// maps a json object with a list of SystemConfigLoggingDto-objects as value to a dart map
static Map<String, List<SystemConfigLoggingDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
final map = <String, List<SystemConfigLoggingDto>>{};
if (json is Map && json.isNotEmpty) {
// ignore: parameter_assignments
json = json.cast<String, dynamic>();
for (final entry in json.entries) {
map[entry.key] = SystemConfigLoggingDto.listFromJson(entry.value, growable: growable,);
}
}
return map;
}
/// The list of required keys that must be present in a JSON.
static const requiredKeys = <String>{
'enabled',
'level',
};
}