• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

wger-project / flutter / 30854254088

03 Aug 2026 09:21PM UTC coverage: 40.895% (-15.0%) from 55.93%
30854254088

Pull #1260

github

web-flow
Merge d93794de5 into e3affdd4f
Pull Request #1260: WIP: health sync

9980 of 24404 relevant lines covered (40.89%)

1.72 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

84.21
/lib/core/logs.dart
1
/*
2
 * This file is part of wger Workout Manager <https://github.com/wger-project>.
3
 * Copyright (c)  2026 wger Team
4
 *
5
 * wger Workout Manager is free software: you can redistribute it and/or modify
6
 * it under the terms of the GNU Affero General Public License as published by
7
 * the Free Software Foundation, either version 3 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU Affero General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU Affero General Public License
16
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
 */
18

19
import 'package:logging/logging.dart';
20

21
/// Stores log entries in memory.
22
///
23
/// This means nothing is stored permanently anywhere and we loose everything
24
/// when the application closes, but that's ok for our use case and can be
25
/// changed in the future if the need arises.
26
class InMemoryLogStore {
27
  static final InMemoryLogStore _instance = InMemoryLogStore._internal();
3✔
28
  final List<LogRecord> _logs = [];
29

30
  factory InMemoryLogStore() => _instance;
2✔
31

32
  InMemoryLogStore._internal();
1✔
33

34
  // Adds a new log entry, but keeps the total number of entries limited
35
  void add(LogRecord record) {
1✔
36
    if (_logs.length >= 500) {
3✔
37
      _logs.removeAt(0);
×
38
    }
39
    _logs.add(record);
2✔
40
  }
41

42
  List<LogRecord> get logs => List.unmodifiable(_logs);
×
43

44
  /// Returns formatted log entries
45
  List<String> getFormattedLogs({Level? minLevel, int maxEntries = 50}) {
1✔
46
    final level = minLevel ?? Logger.root.level;
×
47
    final filtered = _logs.where((log) => log.level >= level).toList();
6✔
48

49
    final start = filtered.length - maxEntries;
2✔
50
    final slice = start > 0 ? filtered.sublist(start) : filtered;
1✔
51

52
    // Return newest entries first (reverse order)
53
    return slice.reversed
1✔
54
        .map(
1✔
55
          (log) =>
1✔
56
              '${log.time.toIso8601String()} ${log.level.name} [${log.loggerName}] ${log.message}',
7✔
57
        )
58
        .toList();
1✔
59
  }
60

61
  void clear() => _logs.clear();
3✔
62
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc