Skip to content

Commit

Permalink
Write example
Browse files Browse the repository at this point in the history
  • Loading branch information
vdakalov committed Jan 20, 2015
1 parent 87f3a27 commit bde1da6
Showing 1 changed file with 86 additions and 2 deletions.
88 changes: 86 additions & 2 deletions example/log.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
library dlog.example;

import "dart:math" as Math;
import 'package:dlog/dlog.dart' as dlog;
import "package:dlog/dlog.dart" as dlog;
import "dart:convert";

double rad(num deg) =>
deg * (Math.PI / 180);
Expand All @@ -22,10 +23,89 @@ List<Map> users = [
}
];

getJSON() {
var data = '''
[
{
"_id": "54bde2ec6d0c45fe2aad89a1",
"index": 0,
"guid": "391ad3b0-e003-44fe-8f52-9a53b0d2ce52",
"isActive": true,
"balance": "\$3,385.54",
"picture": "http://placehold.it/32x32",
"age": 25,
"eyeColor": "blue",
"name": "Burns Avery",
"gender": "male",
"company": "COMTRAIL",
"email": "burnsavery@comtrail.com",
"phone": "+1 (829) 415-3400",
"address": "496 Hemlock Street, Hegins, New Mexico, 4698",
"about": "Qui ex labore irure proident aute veniam sit minim Lorem irure. Est officia quis amet dolor duis velit pariatur culpa elit in aliqua aute magna. Occaecat et proident ut ea sit dolore aliquip. Ipsum minim esse ad et deserunt. Ad sit amet occaecat sint. Ipsum anim commodo ex eiusmod reprehenderit exercitation sit mollit proident aliqua. Occaecat reprehenderit mollit voluptate tempor nostrud qui anim veniam est laboris qui pariatur.\r\n",
"registered": "2014-09-19T00:05:13 -05:00",
"latitude": -2.302439,
"longitude": 92.194414,
"tags": [
"commodo",
"eu",
"deserunt",
"quis",
"dolor",
"nulla",
"ad"
],
"friends": [
{
"id": 0,
"name": "Katheryn Rogers"
},
{
"id": 1,
"name": "Corine Smith"
},
{
"id": 2,
"name": "Jacobson Christensen"
}
],
"greeting": "Hello, Burns Avery! You have 3 unread messages.",
"favoriteFruit": "strawberry"
}
]
'''.replaceAll(new RegExp("\n|\r"), "");
return JSON.decode(data);
}

main() {

var users_tree = new dlog.Tree("Users");
/**************************************
* Json
*/

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

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

// max length for string
json.maxStringLen = 80;

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

// output
print(json);


/**************************************
* Tree
*/

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

for (int i = 0; i < users.length; i++) {
Expand Down Expand Up @@ -64,6 +144,10 @@ main() {
// output tree
print(tree);

/**************************************
* Table
*/

// create new table and specify the column number
var table = new dlog.Table(1);

Expand Down

0 comments on commit bde1da6

Please sign in to comment.