Skip to content
This repository has been archived by the owner on Apr 29, 2021. It is now read-only.

Commit

Permalink
Fixed a bug with name. (#1)
Browse files Browse the repository at this point in the history
* Fixed a bug with name.

* Fix travis.
  • Loading branch information
matanlurey committed Oct 20, 2017
1 parent 7412c10 commit 4a89fb5
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 15 deletions.
15 changes: 6 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,16 @@ language: dart
sudo: false
dart:
- dev
- stable

cache:
directories:
- $HOME/.pub-cache

# Only building master means that we don't run two builds for each pull request.
branches:
only: [master]

dart_task:
- test: --platform vm
install_dartium: true
- dartanalyzer
- dartfmt
matrix:
# Only run dartfmt checks with stable.
exclude:
- dart: dev
dart_task: dartfmt
- dart: dev
dart_task: dartanalyzer
8 changes: 3 additions & 5 deletions lib/cable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,9 @@ String _defaultFormatter(Record<Object> record) {
..write(':')
..write(timestamp.minute)
..write(':')
..write(timestamp.second)
..write(':')
..write(timestamp.millisecond);
final name = record.origin;
return '[${record.severity} @ $timeFormat] $name: ${record.payload}';
..write(timestamp.second);
final name = record.origin != null ? ' ${record.origin}:' : '';
return '[${record.severity} @ $timeFormat]$name ${record.payload}';
}

/// Common and simple implementations of [Sink<Record>].
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ authors:
homepage: https://github.com/matanlurey/cable

environment:
sdk: ">=1.24.0 <2.0.0"
sdk: ">=2.0.0-dev <2.0.0"

dependencies:
meta: ^1.1.0
Expand Down
11 changes: 11 additions & 0 deletions test/cable_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,17 @@ void main() {
endsWith('child: Hello World'),
]);
});

test('timestamp should override the default', () {
final buffer = <String>[];
new Logger(
destinations: [new ListSink(buffer)],
timestamp: () => new DateTime.utc(2017),
).log('Hello World', severity: Severity.warning);
expect(buffer, [
'[warning @ 0:0:0] Hello World',
]);
});
}

/// Simply returns [Record.payload] with `toString()`.
Expand Down

0 comments on commit 4a89fb5

Please sign in to comment.