Logger service using logging package in Angular Dart - dart

There is a mention in the docs of using the logging package to create a proper logger service. Given the features in the logging package it would be nice to be able to get the angular component tree as the logger full name.
I tried to play a bit with the dependency injection system to get the injector tree, so that I could reconstruct the app structure for the loggers. But this proved to be too tricky.
Is there a way to do this, or alternatively, is there a canonical logger service that I could use? It seems to be a pretty basic feature so it must be available somewhere.

I'd look at the logging package for help here.
This is not Angular-specific, but it supports tested loggers.

Related

how to specify configuration(specifically reporter to be used) in playwright-dotnet

I'm beginner in C#.net. Is there a way to have a configuration file for playwright-dotnet similar to playwright.conf.js(js version). As the config file made it easier to specify most configurations in one place!
There is no mention of config in playwright documentation for .net version. I became aware of ".runsettings" for playwright-dotnet which I used to specify browsers to be used, but couldn't get a proper understanding on report integration!

OAI-PMH - creation of endpoint

I would like to create an oai-pmh endpoint to publish metadata to. However, I'm having a little trouble seeing how to do it. I see that several solutions are available to me via Dspace or Fedora. But I would like to create it myself in python, do you know any modules that can do this? Because I found the pyoai module but it's more for harvesting than for publishing.

which is the best way for configure log4j2

I am developing one automation testing framework for a web application testing. For this automation framework I want implement logging with log4j2.
In web I found that there is 4 different way to configure the log4j2 configuration
1) .xml
2) .yml
3) .properties
4) .json
I am confuse which configuration will be better for which purpose. Can anyone explain me for what kind of application/situation which configuration is suitable.
Also I want to know how I can implement log4j2 from start to end (any link)
You're completely free to use any! It's a matter of personal preference.
You can see that they have the same capabilities in the configuration documentation.
A properties file is definitely the simplest, but there's probably more documentation using XML. YAML is much richer, I would start with either properties or XML.

How can I load code from another Dart package, known only at runtime?

I am building a Dart application. It needs to load code from a third-party package, which is only known at runtime. My application needs to:
auto-discover the dependency
load a library from that dependency
interact with the dependency
Ideally, I do not want to require that my users specify the third-party dependency. The application should auto-discover the dependency.
For example, a workflow could be something like this:
User installs my app (pub global activate my_app)
User installs a "plugin" (pub global activate plugin_for_my_app)
User runs my app (my_app)
The app auto-discovers that plugin_for_my_app exists.
The app loads the plugin (via spawnUri perhaps?)
The app calls into the plugin
Requirements:
Must run from the command-line.
Must work on Windows, Mac, Linux.
Should (but doesn't have to) run when compiled to JavaScript.
pub run support is optional (pub run makes it tricky, because it rewrites your import URIs, so it's not a requirement)
What's the best way to do this?
This package https://pub.dartlang.org/packages/plugins seems to do exactly what you want (haven't used it myself yet though) by loading plugins into isolates.
This is not directly answering the question (CL tools as requested), but I use plugins in the browser and wanted to share my "pattern".
My web application imports includes.dart which is a dynamically generated file that imports all .dart files found in a specified directory. The file gets (re-)generated at app startup by the backend, just before serving the files to the browser. The found .dart files implement a public api (eg. init() and run()) so that the main application can call their code. The plugin code are not loaded into separate isolates but are executed in the same isolate as the main app which gives the benefit of plugins sharing the same heap and you're able to access the plugin code directly. This solution also assumes the plugins resolve their own dependencies.
This setup works fairly well for my use case. However, as there's no real dynamic code reloading in Dart (yet, I hope. see https://code.google.com/p/dart/issues/detail?id=10530), there's always a refresh step needed to load the new code.
In the plugins package, currently, there is no way to resolve dependencies through pub. When I originally designed the API it was assumed that the dependencies were already retrieved through pub get. With that said, plugin discovery on the file system is simple.
As you can see in the example in the README, loading plugins was as simple as new PluginManager().loadAll(String directory) which would automatically discover all plugins inside the directory and load them. This solution is ideal if all plugins are to be in one folder.
It is possible to do individual plugin directory loading as well, provided it follows the plugin directory structure. Using a PluginLoader you can load in a directory that contains the necessary files for a plugin to run properly. It is not necessary to call load() since the PluginManager will take care of calling in load for you.
A simplified way of loading a plugin
Instantiate the PluginManager.
PluginManager pm = new PluginManager();
Determine the plugin you want loaded. The plugins library will automatically
determine the pub cache directory. As per the documentation of pub, the PUB_CACHE environment variable is also supported.
Load in the plugin. A Future is returned with a Plugin object that provides basic information about the plugin. The plugin requires a pubspec.yaml with a name, a packages directory, and a bin/main.dart source file. However we are loading from the pub cache, so we do not need to worry about the setup of the plugin, the only requirement is the package from the pub cache supports the plugins package.
pm.loadFromCache("test-1.0.0").then((Plugin plugin) {
print("Plugin loaded!");
handle();
});
After all the plugins you desire to be loaded are initialized, the manager can now listen for requests properly. Simply use the listener to 'see' the incoming data.
The plugin side
The plugin simply uses a receiver as provided by the plugins API.
void main(List<String> args, SendPort port) {
Receiver rec = new Receiver(port);
rec.listen((Map<dynamic, dynamic> data) {
print("Received data: $data");
});
}
I wrapped the plugins package with a bit of sugar to provide some extra things like declarative RPC. It's very flexible, and samrg472 (the author of plugins.dart) is a good friend, so I have asked him to comment as well.
https://github.com/PolymorphicBot/PolymorphicBot/blob/master/lib/src/core/plugins/handler.dart

PHPStorm, Silex DI indices code completion

I'm trying PHPStorm and have trouble with its code completion. I write project with Silex framework and faced PHPStorm's lack of code completion for Silex dependency injection container. For example, it doesnt codecomplete $app['twig']-> or $app['db']-> or any other service. The only way solution I've found is to do smth like this
$db = $app['db'];
/** #var $db \Doctrine\DBAL\Connection */
$db->....
And then PHPStorm will do code completion. Services are registered using ServiceProvider interface.
Is there a way to make PHPStorm do code completion in such cases without additional vars and comments?
As far as I'm aware, this is currently not possible, however, there is currently work going on to add support for generic factory patterns, see this issue on their issue-tracker:
http://youtrack.jetbrains.com/issue/WI-6027
The PhpStorm developers welcome new feature requests on their issue tracker and are quite responsive. So you may file a feature request
Also, this may be related to your question:
http://youtrack.jetbrains.com/issue/WI-5304
Here's a plugin for PHPStorm / Intellij IDEA:
https://plugins.jetbrains.com/plugin/7809?pr=
Didn't tried it yet, but looks promising...
Edit: Just gave it a quick shot, and it looks really cool and simple to set up:
Install the plugin via the IDE plugin manager
Add the following dependency:
"require": {
"sorien/silex-pimple-dumper": "~1.0"
}
Register the provider:
$app->register(new Sorien\Provider\PimpleDumpProvider());
And you are done.

Resources