Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(532)

Side by Side Diff: pkg/barback/test/transformer/log.dart

Issue 108853003: Pass logs through transformer groups. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix test suite name. Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/barback/test/mutliset_test.dart ('k') | pkg/barback/test/utils.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 library barback.test.transformer.log;
6
7 import 'dart:async';
8
9 import 'package:barback/barback.dart';
10 import 'package:barback/src/utils.dart';
11
12 import 'mock.dart';
13
14 /// A transformer that logs given entries during its apply.
15 class LogTransformer extends MockTransformer {
16 /// The list of entries that it should log.
17 ///
18 /// Each entry has the log level followed by the message, like:
19 ///
20 /// error: This is the error message.
21 final List<String> _entries;
22
23 LogTransformer(this._entries);
24
25 Future<bool> doIsPrimary(Asset asset) => new Future.value(true);
26
27 Future doApply(Transform transform) {
28 return newFuture(() {
29 for (var entry in _entries) {
30 var parts = entry.split(":");
31 var logFn;
32 switch (parts[0]) {
33 case "error": logFn = transform.logger.error; break;
34 case "warning": logFn = transform.logger.warning; break;
35 case "info": logFn = transform.logger.info; break;
36 }
37
38 logFn(parts[1].trim());
39 }
40 });
41 }
42 }
OLDNEW
« no previous file with comments | « pkg/barback/test/mutliset_test.dart ('k') | pkg/barback/test/utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698