Skip to content

Commit

Permalink
Change api
Browse files Browse the repository at this point in the history
  • Loading branch information
vdakalov committed Jan 22, 2015
1 parent 8fedb75 commit 3c1695f
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 18 deletions.
23 changes: 10 additions & 13 deletions example/json.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,30 +61,27 @@ getJSON() {

main() {

/**************************************
* Json
*/

// create Json object and
var json = new dlog.Json(
var debug = new dlog.Json(
title: "My",
data: new List()
);

json.data = getJSON();
json.title += " json";
debug.data = getJSON();
debug.title += " json";

// max length for string (set null for output full string)
json.maxStringLen = 50;
debug.maxStringLen = 50;

// custom data parsers (custom parsers for List, Map and String types will be ignored)
json.parsers["int"] = (int num) => "$num <-- int";
debug.parsers["int"] = (int num) => "$num <-- int";

// output
print(json);
print(debug);

json.flush = true;
json.maxStringLen = 10;
print(json);
// no clear buffer [by default: true]
debug.flush = false;
debug.maxStringLen = 10;
print(debug);

}
40 changes: 40 additions & 0 deletions example/time.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright (c) 2015, Viktor Dakalov. All rights reserved. Use of this source code
// is governed by a BSD-style license that can be found in the LICENSE file.

library dlog.example.time;

import "dart:math";
import "package:dlog/dlog.dart" as dlog;

// a function that is performed for a long time
power() {
int len = 1000;
while (len-- > 0) {
sqrt(pow(new Random().nextDouble(), new Random().nextDouble()));
}
}

power2() {
power();
}

power3() {
power();
}

main() {

// create Time object and specity descrption
// object can be used throughout the application
var debug = new dlog.Time("Cycle")..init();

// call check after separated logic operation
debug.checkFunc("once call power", power);

// call power several times
debug.checkLoopFunc("call power in loop 10", 10, power3);

// output
print(debug);

}
9 changes: 4 additions & 5 deletions example/tree.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,18 @@ List<Map> users = [

main() {

var users_tree = new dlog.Tree("Users");
users_tree.openGroup();
var debug = new dlog.Tree("Users");
debug.openGroup();

for (int i = 0; i < users.length; i++) {
users_tree..add(users[i]["name"])
debug..add(users[i]["name"])
..openGroup()
..add("age: ${users[i]["age"]}")
..add("city: ${users[i]["city"]}")
..closeGroup()
;
}

// users_tree.closeGroup();
print(users_tree..closeGroup());
print(debug..closeGroup());

}
5 changes: 5 additions & 0 deletions lib/src/displays/Time.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ class Time extends _Display {
_registerAction(description);
}

checkLoopFunc(String description, num count, Function doit) {
while (count-- > 0) { doit(); }
_registerAction(description);
}

@override
_initBuffer() {

Expand Down

0 comments on commit 3c1695f

Please sign in to comment.