pip_services3_elasticsearch 1.1.0 copy "pip_services3_elasticsearch: ^1.1.0" to clipboard
pip_services3_elasticsearch: ^1.1.0 copied to clipboard

This component library is a part of the [Pip.Services](https://github.com/pip-services/pip-services) project. It contains the ElasticSearch logger.

example/main.dart

import 'dart:io';
import 'package:pip_services3_commons/pip_services3_commons.dart';
import 'package:pip_services3_components/pip_services3_components.dart';
import 'package:pip_services3_elasticsearch/pip_services3_elasticsearch.dart';

void main() async {
  var host = Platform.environment['ELASTICSEARCH_SERVICE_HOST'] ?? 'localhost';
  var port = Platform.environment['ELASTICSEARCH_SERVICE_PORT'] ?? 9200;
  var dateFormat = 'yyyyMMdd';

  var _logger = ElasticSearchLogger();

  var config = ConfigParams.fromTuples([
    'source',
    'test',
    'index',
    'log',
    'daily',
    true,
    'date_format',
    dateFormat,
    'connection.host',
    host,
    'connection.port',
    port
  ]);
  _logger.configure(config);

  await _logger.open(null);

  _logger.setLevel(LogLevel.Trace);
  _logger.fatal(null, null, 'Fatal error message');
  _logger.error(null, null, 'Error message');
  _logger.warn(null, 'Warning message');
  _logger.info(null, 'Information message');
  _logger.debug(null, 'Debug message');
  _logger.trace(null, 'Trace message');

  try {
    // Raise an exception
    throw Exception('Test error');
  } catch (err) {
    var ex = ApplicationException().wrap(err);
    _logger.fatal('123', ex, 'Fatal error');
    _logger.error('123', ex, 'Recoverable error');
  }

  _logger.dump();

  await _logger.close(null);
}
0
likes
115
pub points
0%
popularity

Publisher

verified publisherentinco.com

This component library is a part of the [Pip.Services](https://github.com/pip-services/pip-services) project. It contains the ElasticSearch logger.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

elastic_client, intl, pip_services3_commons, pip_services3_components, pip_services3_rpc

More

Packages that depend on pip_services3_elasticsearch