Skip to content

Commit 01aa9e1

Browse files
committed
Revert "Add platform detection"
This reverts commit 625c0dc. Platform detection was not working. The booleans `isWeb` and `isVM` always stayed `false`.
1 parent cc884b6 commit 01aa9e1

File tree

9 files changed

+19
-307
lines changed

9 files changed

+19
-307
lines changed

README.md

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -96,20 +96,15 @@ var logger = Logger(
9696
);
9797
```
9898

99-
### Auto Detecting Platform
99+
### Auto detecting
100100

101-
The class `LogPlatform` tries to automatically identify `lineLength` and `colors`
102-
support for console output, depending on the detected platform (VM or Web).
101+
With the `io` package you can auto detect the `lineLength` and `colors` arguments.
102+
Assuming you have imported the `io` package with `import 'dart:io' as io;` you
103+
can auto detect `colors` with `io.stdout.supportsAnsiEscapes` and `lineLength`
104+
with `io.stdout.terminalColumns`.
103105

104-
If in VM platform it uses `dart:io` (`colors` with `io.stdout.supportsAnsiEscapes`
105-
and `lineLength` with `io.stdout.terminalColumns`).
106-
107-
If you want to allow output in `stderr` (if present in the runtime platform),
108-
you should enable it:
109-
110-
```dart
111-
LogPlatform.enableSTDERR = true ;
112-
```
106+
You should probably do this unless there's a good reason you don't want to
107+
import `io`, for example when using this library on the web.
113108

114109
## LogFilter
115110

lib/logger.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ export 'src/printers/simple_printer.dart';
1717
export 'src/printers/hybrid_printer.dart';
1818
export 'src/printers/prefix_printer.dart';
1919

20-
export 'src/platform/platform.dart';
21-
2220
export 'src/log_output.dart'
2321
if (dart.library.io) 'src/outputs/file_output.dart';
2422

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
import 'package:logger/src/logger.dart';
22
import 'package:logger/src/log_output.dart';
3-
import 'package:logger/src/platform/platform.dart';
43

54
/// Default implementation of [LogOutput].
65
///
76
/// It sends everything to the system console.
87
class ConsoleOutput extends LogOutput {
98
@override
109
void output(OutputEvent event) {
11-
var allLines = LogPlatform.joinLines(event.lines, event.level);
12-
var printer = LogPlatform.getConsolePrinter(event.level);
13-
14-
printer(allLines);
10+
event.lines.forEach(print);
1511
}
1612
}

lib/src/platform/platform.dart

Lines changed: 0 additions & 124 deletions
This file was deleted.

lib/src/platform/platform_standard.dart

Lines changed: 0 additions & 21 deletions
This file was deleted.

lib/src/platform/platform_vm.dart

Lines changed: 0 additions & 51 deletions
This file was deleted.

lib/src/platform/platform_web.dart

Lines changed: 0 additions & 54 deletions
This file was deleted.

lib/src/printers/pretty_printer.dart

Lines changed: 9 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import 'dart:convert';
22

3-
import 'package:logger/src/ansi_color.dart';
43
import 'package:logger/src/logger.dart';
54
import 'package:logger/src/log_printer.dart';
6-
import 'package:logger/src/platform/platform.dart';
5+
import 'package:logger/src/ansi_color.dart';
76

87
/// Default implementation of [LogPrinter].
98
///
10-
/// Output looks like this:
9+
/// Outut looks like this:
1110
/// ```
1211
/// ┌──────────────────────────
1312
/// │ Error info
@@ -64,52 +63,30 @@ class PrettyPrinter extends LogPrinter {
6463

6564
static DateTime _startTime;
6665

67-
/// Amount of [StackTrace] lines to show with message (non-error log).
68-
/// Defaults to LogPlatform.DEFAULT_METHOD_COUNT.
6966
final int methodCount;
70-
71-
/// Amount of error [StackTrace] lines to show with message.
72-
/// Defaults to LogPlatform.DEFAULT_ERROR_METHOD_COUNT.
7367
final int errorMethodCount;
74-
75-
/// Columns length to format log.
76-
/// Defaults to LogPlatform.DEFAULT_LINE_LENGTH.
7768
final int lineLength;
78-
79-
/// If [true] uses colors for logging.
80-
/// Defaults to LogPlatform.DEFAULT_USE_COLORS.
8169
final bool colors;
82-
83-
/// If [true] uses emojis to identify logging types.
84-
/// Defaults to LogPlatform.DEFAULT_USE_EMOJI.
8570
final bool printEmojis;
86-
87-
/// If [true] shows a line with log event time.
88-
/// Defaults to false.
8971
final bool printTime;
9072

9173
String _topBorder = '';
9274
String _middleBorder = '';
9375
String _bottomBorder = '';
9476

9577
PrettyPrinter({
96-
int methodCount,
97-
int errorMethodCount,
98-
int lineLength,
99-
bool colors,
100-
bool printEmojis,
78+
this.methodCount = 2,
79+
this.errorMethodCount = 8,
80+
this.lineLength = 120,
81+
this.colors = true,
82+
this.printEmojis = true,
10183
this.printTime = false,
102-
}) : methodCount = methodCount ?? LogPlatform.DEFAULT_METHOD_COUNT,
103-
errorMethodCount =
104-
errorMethodCount ?? LogPlatform.DEFAULT_ERROR_METHOD_COUNT,
105-
lineLength = lineLength ?? LogPlatform.DEFAULT_LINE_LENGTH,
106-
colors = colors ?? LogPlatform.DEFAULT_USE_COLORS,
107-
printEmojis = printEmojis ?? LogPlatform.DEFAULT_USE_EMOJI {
84+
}) {
10885
_startTime ??= DateTime.now();
10986

11087
var doubleDividerLine = StringBuffer();
11188
var singleDividerLine = StringBuffer();
112-
for (var i = 0; i < this.lineLength - 1; i++) {
89+
for (var i = 0; i < lineLength - 1; i++) {
11390
doubleDividerLine.write(doubleDivider);
11491
singleDividerLine.write(singleDivider);
11592
}

0 commit comments

Comments
 (0)