Permalink
Browse files

doc: Changed documentation in README

  • Loading branch information...
MikeMitterer committed Dec 6, 2017
1 parent a31d7df commit 9ef9d39c723ec505e855a484c7a02c885e31592b
@@ -28,7 +28,7 @@ void configLogging() {
// now control the logging.
// Turn off all logging first
Logger.root.level = Level.INFO;
Logger.root.onRecord.listen(new LogConsoleHandler());
Logger.root.onRecord.listen(logToConsole);
}
```

@@ -37,7 +37,7 @@ void configLogging() {

### License

Copyright 2016 Michael Mitterer (office@mikemitterer.at),
Copyright 2017 Michael Mitterer (office@mikemitterer.at),
IT-Consulting and Development Limited, Austrian Branch

Licensed under the Apache License, Version 2.0 (the "License");
@@ -52,11 +52,6 @@ void configLogging() {
either express or implied. See the License for the specific language
governing permissions and limitations under the License.

### Thanks

I used Chris Buckett's (chrisbuckett@gmail.com) [logging_handler][4] library for my work.
Thank's Chris!

If this plugin is helpful for you - please [(Circle)](http://gplus.mikemitterer.at/) me.

[1]: https://raw.githubusercontent.com/MikeMitterer/dart-console_log_handler/master/doc/_resources/screenshot.png
Binary file not shown.
@@ -5,7 +5,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="description" content="A front-end template that helps you build fast, modern mobile web apps.">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Material Design Lite</title>
<title>Sample</title>
</head>

<body>
@@ -6,6 +6,8 @@ main() async {
final Logger _logger = new Logger("unit.test.Logging");
configLogging();

_logger.info("This is a log message!");

final Map<String, dynamic> map = {
"firstname" : "Mike", "lastname" : "Mitterer {{var}}", "family" : {
"daughter" : "Sarah", "age" : 18
@@ -22,24 +24,6 @@ main() async {
}
}

String myTransformer(final LogRecord logRecord) {
final shortLoggerName = logRecord.loggerName.replaceAll(new RegExp('^.+\\.'), "");
final dateFormat = new DateFormat("HH:mm:ss.SSS");

String time;
if (logRecord.time != null) {
time = dateFormat.format(logRecord.time);
} else {
time = dateFormat.format(new DateTime.now());
}
if (logRecord.error != null) {
return "$time ${logRecord.level} ${shortLoggerName.padRight(10)} ${logRecord.message} / ${logRecord.error}";

} else {
return "$time ${logRecord.level} ${shortLoggerName.padRight(10)} ${logRecord.message}";
}
}

void configLogging() {
hierarchicalLoggingEnabled = true;
Logger.root.level = Level.INFO;
@@ -1,6 +1,7 @@
library console_log_handler;

import 'dart:html';
import 'dart:math';
import "dart:convert";
import "package:intl/intl.dart";

@@ -122,22 +123,29 @@ class LogConsoleHandler {
}

String defaultTransformer(final LogRecord logRecord,{ final int nameWidth = 20 }) {
String shortLoggerName = logRecord.loggerName.replaceAll(new RegExp('^.+\\.'), "");
final dateFormat = new DateFormat("HH:mm:ss.SSS");

String loggerName = logRecord.loggerName.substring(max(0,logRecord.loggerName.length - nameWidth));
String shortLoggerName = logRecord.loggerName.replaceAll(new RegExp('^.+\\.'), "");

String time;
if (logRecord.time != null) {
time = dateFormat.format(logRecord.time);
} else {
time = dateFormat.format(new DateTime.now());
}

shortLoggerName.padRight(nameWidth);
if(loggerName.length > nameWidth) {
loggerName = shortLoggerName;
}
loggerName += ":";
loggerName = loggerName.padRight(nameWidth);

if (logRecord.error != null) {
return "$time ${logRecord.level} ${shortLoggerName} ${logRecord.message} / ${logRecord.error}";
return "$time [${logRecord.level}] ${loggerName} ${logRecord.message} / ${logRecord.error}";

} else {
return "$time ${logRecord.level} ${shortLoggerName} ${logRecord.message}";
return "$time [${logRecord.level}] ${loggerName} ${logRecord.message}";
}
}

0 comments on commit 9ef9d39

Please sign in to comment.