log4dart 2.0.0

  • Readme
  • Changelog
  • Installing
  • 49

Build Status Coverage Status

Log4Dart #

Logging library with multiple appenders, configurable formatting and log tracing.

Getting Started #

1. Add the folowing to your pubspec.yaml and run pub install

	dependencies:
	  log4dart: any

2. Add log4dart to some code and run it

	import "package:log4dart/log4dart.dart";
	
	main() {
		var myClass = new MyClass();
		myClass.someMethod();
	}
		
	class MyClass {
		static final _logger = LoggerFactory.getLoggerFor(MyClass);
	
		someMethod() {
			_logger.info("a info message");
			// :
			_logger.warnFormat("%s %s", ["message", "formatting"]);
		}
	}

Creating Loggers #

Log4Dart is split in multiple libraries so it can run on both servers and in browsers.

// for client side logging (works both on the VM and when compiled to JS)
import "package:log4dart/log4dart.dart";

// for VM logging, allows you to log to files (does not compile to JS) 
import "package:log4dart/log4dart_vm.dart";

When you want to retrieve a logger instance you can do it in one of two ways

  1. LoggerFactory.getLoggerFor(MyClass) - logger with the fully qualified name of MyClass
  2. LoggerFactory.getLogger("MyClass") - logger with the name "MyClass"

Where the qualified name is the library name and type name concatenated together.

More Information #

The configuration guide covers everything from log level setup to output formatting. For more advanced features, such as log tracing, check out the advanced feature guide.

2.0.0

  • Updated to work with Dart 2

1.4.18

  • Remove dependency on meta package

1.4.17

  • Correct copyright message

1.4.16

  • Bump dependencies

1.4.15

  • Rewrite tests to gain better code coverage

1.4.14

  • Further fixes to organize project to work with Travis CI

1.4.13

  • Switch to Travis CI

1.4.12

  • Switch to new Dart test library

1.4.11

  • Add changelog

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  log4dart: ^2.0.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:log4dart/log4dart.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
33
Health:
Code health derived from static analysis. [more]
56
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
49
Learn more about scoring.

We analyzed this package on Apr 7, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6

Health issues and suggestions

Fix lib/src/logger_config.dart. (-26.86 points)

Analysis of lib/src/logger_config.dart failed with 1 error, 5 hints, including:

line 64 col 17: 'LoggerConfig.==' ('bool Function(LoggerConfig)') isn't a valid override of 'Object.==' ('bool Function(dynamic)').

line 10 col 20: Unnecessary new keyword.

line 12 col 3: Prefer using /// for doc comments.

line 26 col 3: Prefer using /// for doc comments.

line 28 col 24: Unnecessary new keyword.

Fix lib/src/logger.dart. (-8.63 points)

Analysis of lib/src/logger.dart reported 18 hints, including:

line 7 col 1: Prefer using /// for doc comments.

line 13 col 3: Prefer using /// for doc comments.

line 16 col 3: Prefer using /// for doc comments.

line 19 col 3: Prefer using /// for doc comments.

line 22 col 3: Prefer using /// for doc comments.

Fix lib/src/logger_factory.dart. (-5.36 points)

Analysis of lib/src/logger_factory.dart reported 11 hints, including:

line 7 col 1: Prefer using /// for doc comments.

line 16 col 36: Unnecessary new keyword.

line 18 col 3: Prefer using /// for doc comments.

line 29 col 3: Prefer using /// for doc comments.

line 37 col 3: Prefer using /// for doc comments.

Fix additional 9 files with analysis or formatting issues. (-20.27 points)

Additional issues in the following files:

  • lib/src/log_record_formatter.dart (9 hints)
  • lib/src/logger_config_map.dart (7 hints)
  • lib/src/appender.dart (5 hints)
  • lib/src/appenders/file_appender.dart (5 hints)
  • lib/src/appenders/string_appender.dart (5 hints)
  • lib/src/logger_impl.dart (5 hints)
  • lib/src/log_record.dart (3 hints)
  • lib/log4dart_vm.dart (1 hint)
  • lib/src/appenders/console_appender.dart (1 hint)

Maintenance issues and suggestions

No valid SDK. (-20 points)

The analysis could not detect a valid SDK that can use this package.

Maintain an example.

None of the files in the package's example/ directory matches known example patterns.

Common filename patterns include main.dart, example.dart, and log4dart.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
sprintf ^4.0.2 4.0.2
Dev dependencies
test any