Skip to content

Commit

Permalink
Adding travis build file
Browse files Browse the repository at this point in the history
  • Loading branch information
ericmartineau committed Mar 23, 2020
1 parent 4f6fd09 commit b88cc5b
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 92 deletions.
23 changes: 23 additions & 0 deletions .travis.yml
@@ -0,0 +1,23 @@
os:
- linux
sudo: false
addons:
apt:
# Flutter depends on /usr/lib/x86_64-linux-gnu/libstdc++.so.6 version GLIBCXX_3.4.18
sources:
- ubuntu-toolchain-r-test # if we don't specify this, the libstdc++6 we get is the wrong version
packages:
- libstdc++6
- fonts-droid-fallback
before_script:
- git clone https://github.com/flutter/flutter.git -b beta
- export PATH=`pwd`/flutter/bin:`pwd`/flutter/bin/cache/dart-sdk/bin:$PATH
- flutter doctor
- gem install coveralls-lcov
script:
- flutter test --coverage
after_success:
- coveralls-lcov coverage/lcov.info
cache:
directories:
- $HOME/.pub-cache
1 change: 1 addition & 0 deletions CHANGELOG.md
@@ -1,3 +1,4 @@
## [0.4.7] - Web support
## [0.4.5] - Official release of isolate_service
## [0.4.4] - Initial release

10 changes: 5 additions & 5 deletions lib/console_web.dart
Expand Up @@ -2,18 +2,18 @@
library console_web; // required library declaration called main, or whatever name you wish

import 'package:js/js.dart';
import 'package:logging/logging.dart'; // Pull in our dependency
import 'package:logging/logging.dart';

@JS('console.info') // This marks the annotated function as a call to `console.log`
@JS('console.info')
external void _info(dynamic str);

@JS('console.error') // This marks the annotated function as a call to `console.log`
@JS('console.error')
external void _error(dynamic str);

@JS('console.debug') // This marks the annotated function as a call to `console.log`
@JS('console.debug')
external void _debug(dynamic str);

@JS('console.warn') // This marks the annotated function as a call to `console.log`
@JS('console.warn')
external void _warn(dynamic str);

typedef LogMethod = void Function(dynamic message);
Expand Down
23 changes: 15 additions & 8 deletions lib/logging_config.dart
Expand Up @@ -3,12 +3,12 @@ library logging_config;
import 'dart:async';
import 'dart:developer' as dev;

import 'package:isolate_service/isolate_service.dart';
import 'package:logging/logging.dart';
import 'console_interface.dart'
if (dart.library.io) 'console_io.dart'
if (dart.library.js) 'console_web.dart';
import 'package:worker_service/worker_service.dart';

import 'console_interface.dart'
if (dart.library.io) 'console_io.dart'
if (dart.library.js) 'console_web.dart';

/// Logging stream consumer
typedef Logging = void Function(LogRecord record);
Expand Down Expand Up @@ -54,12 +54,18 @@ class LogConfig {
/// logs
final LoggingHandler handler;

LogConfig.single({String loggerName = "", Level level = Level.INFO, this.handler = const ConsoleHandler()})
LogConfig.single(
{String loggerName = "",
Level level = Level.INFO,
this.handler = const ConsoleHandler()})
: logLevels = {loggerName: level};

LogConfig.root(Level level, {this.handler = const ConsoleHandler()}) : logLevels = {"": level ?? Level.INFO};
LogConfig.root(Level level, {this.handler = const ConsoleHandler()})
: logLevels = {"": level ?? Level.INFO};

LogConfig({this.logLevels = const <String, Level>{}, this.handler = const ConsoleHandler()});
LogConfig(
{this.logLevels = const <String, Level>{"": Level.INFO},
this.handler = const ConsoleHandler()});
}

abstract class LoggingHandler {
Expand All @@ -86,7 +92,8 @@ class LoggerState {
final LoggingHandler handler;
final StreamSubscription<LogRecord> subscription;

LoggerState(this.logger, this.handler) : subscription = handler.listenTo(logger);
LoggerState(this.logger, this.handler)
: subscription = handler.listenTo(logger);
}

final _loggers = <String, LoggerState>{};
Expand Down
20 changes: 10 additions & 10 deletions pubspec.lock
Expand Up @@ -81,13 +81,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.3"
isolate_service:
dependency: "direct main"
description:
path: "../isolate_service"
relative: true
source: path
version: "0.4.7"
js:
dependency: "direct main"
description:
Expand Down Expand Up @@ -124,12 +117,12 @@ packages:
source: hosted
version: "1.6.4"
pedantic:
dependency: transitive
dependency: "direct main"
description:
name: pedantic
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0+1"
version: "1.9.0"
petitparser:
dependency: transitive
description:
Expand Down Expand Up @@ -190,7 +183,7 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.15"
version: "0.2.11"
typed_data:
dependency: transitive
description:
Expand All @@ -205,6 +198,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.8"
worker_service:
dependency: "direct main"
description:
name: worker_service
url: "https://pub.dartlang.org"
source: hosted
version: "0.5.1"
xml:
dependency: transitive
description:
Expand Down
42 changes: 6 additions & 36 deletions pubspec.yaml
@@ -1,6 +1,6 @@
name: logging_config
description: A plugin that makes it easier to configure logging handlers and output, including loggers in isolates
version: 0.4.5
version: 0.4.7
homepage: https://github.com/SunnyApp/logging_config

environment:
Expand All @@ -11,46 +11,16 @@ dependencies:
sdk: flutter
js: ^0.6.1+1
logging: ^0.11.4
isolate_service:
path: ../isolate_service
worker_service: ^0.5.1
pedantic: ^1.9.0

dev_dependencies:
flutter_test:
sdk: flutter

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

dependency_overrides:
pedantic: ^1.9.0
# The following section is specific to Flutter.
flutter:

# To add assets to your package, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
#
# For details regarding assets in packages, see
# https://flutter.dev/assets-and-images/#from-packages
#
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.

# To add custom fonts to your package, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts in packages, see
# https://flutter.dev/custom-fonts/#from-packages
flutter:
70 changes: 37 additions & 33 deletions test/logging_config_test.dart
Expand Up @@ -2,47 +2,51 @@ import 'dart:async';
import 'dart:isolate';

import 'package:flutter_test/flutter_test.dart';
import 'package:isolate_service/isolate_service.dart';
import 'package:logging/logging.dart';
import 'package:logging_config/logging_config.dart';
import 'package:worker_service/worker_service.dart';

void main() {
setUpAll(() {
configureLogging(LogConfig(handler: CapturingLogger()));
});
group("Logging tests", () {
setUp(() {
configureLogging(LogConfig(handler: CapturingLogger()));
});

test("logs bubble up to root", () async {
final logger = Logger("bubbles");
logger.warning("Hey he hey!!");
logger.info("FOYOINFO");
logger.config("Configy");
test("logs bubble up to root", () async {
final logger = Logger("bubbles");
logger.warning("Hey he hey!!");
logger.info("FOYOINFO");
logger.config("Configy");

await Future.delayed(Duration(seconds: 1));
await Future.delayed(Duration(seconds: 1));

expect(logs.length, equals(2));
expect(logs.first.message, equals("Hey he hey!!"));
});
expect(logs.length, equals(2));
expect(logs.first.message, equals("Hey he hey!!"));
});

test("logs in isolate work", () async {
configureLogging(LogConfig.single(
loggerName: "bubbles",
level: Level.FINER,
handler: CapturingLogger()));
final runner = RunnerFactory.global.create((isolate) => isolate
..debugName = "logTest"
..poolSize = 3);
try {
await runner.run(
logInIsolate, LogRecord(Level.WARNING, "I'm rad", "bubbles"));
await runner.run(logInIsolate,
LogRecord(Level.FINER, "Fine should still show up", "bubbles"));
await runner.run(logInIsolate,
LogRecord(Level.FINER, "No fine except bubbles", "unknown"));
} finally {
runner.close();
}
await Future.delayed(Duration(seconds: 1));

test("logs in isolate work", () async {
configureLogging(LogConfig.single(
loggerName: "bubbles", level: Level.FINER, handler: CapturingLogger()));
final runner = RunnerFactory.global.create((isolate) => isolate
..debugName = "logTest"
..poolSize = 3);
try {
await runner.run(
logInIsolate, LogRecord(Level.WARNING, "I'm rad", "bubbles"));
await runner.run(logInIsolate,
LogRecord(Level.FINER, "Fine should still show up", "bubbles"));
await runner.run(logInIsolate,
LogRecord(Level.FINER, "No fine except bubbles", "unknown"));
} finally {
runner.close();
}
await Future.delayed(Duration(seconds: 1));

expect(logs.length, equals(2));
expect(logs.first.message, equals("Hey he hey!!"));
expect(logs.length, equals(2));
expect(logs.first.message, equals("Hey he hey!!"));
});
});
}

Expand Down

0 comments on commit b88cc5b

Please sign in to comment.