Serilog Appsettings and setting filters - appsettings

Using the Serilog.Settings.AppSettings project I am having difficulty setting a filter to exclude certain namespaces from a configured sink.
In code I would do something like this:
[...].Filter.ByExcluding(Matching.FromSource<MyNameSpace>())
However I don't seem able to do it using the app settings.
Is this supported and if so how can I achieve this using configuration?
Thanks
Vincent

Make sure you have the package.
Install-Package Serilog.Filters.Expressions
Then follow the example here: https://github.com/serilog/serilog-filters-expressions and https://github.com/serilog/serilog-settings-configuration/blob/dev/sample/Sample/appsettings.json#L64
"Using": ["Serilog.Settings.Configuration"],
"Filter": [
{
"Name": "ByIncludingOnly",
"Args": {
"expression": "SourceContext = 'MyNameSpace'"
}
}
]

Related

How can I use the regex_features in my trainning data

How can I use regex_features in json format?
I have just started using rasa-nlu. I have installed and ran the demo successfully - it works well. But I have juest tried by common_examples.
{"rasa_nlu_data":{"common_examples":[],"regex_features":[{"name":"zipcode","pattern":"[0-9]{5}"},{"name":"greet","pattern":"hello[^\\s]*"}]}}
Now I want to know how to use regex_features and how does it works. It will be better to have some examples.
Thanks a lot!
Check out the documentation of Rasa here.
The example is
{
"rasa_nlu_data": {
"regex_features": [
{
"name": "zipcode",
"pattern": "[0-9]{5}"
},
{
"name": "greet",
"pattern": "hey[^\\s]*"
},
]
}
}
Also make sure that the RegexFeaturizer component is part of your NLU pipeline. I further suggest to update to Rasa 1.x which contains both Rasa Core and NLU, since rasa_nlu will not longer be maintained as single package. Also the Rasa Forum is a good place for getting help on Rasa.

What is the best way to read settings for UI Xamarin test from json file with DI?

I have a few tests which read data out of config.json file for determining the test details of each platform.
They look like this
{
"Devices" : {
"Settings": [
{
"Platform": "iOS",
"SerialNumbers": [
"b509b42b821a0b2eeb58ed5659e504c118d0323c"
],
"AssemblyPath": "realbundlename"
},
{
"Platform": "Android",
"SerialNumbers": [
"ZX1G22VMH7"
],
"AssemblyPath": "../../../Droid/bin/Release/nameoffile.apk"
}
]
}
}
The question is how to read data from json in UI Test App project.
I try to use Autofac and read data with module functionality, but when I debug I got that data not read from the file. I guess the problem with the type of project.
I try to develop it as in this article.
Does anyone know what the best way to do this is?
Or maybe someone has better idea how to read data from .json?
Use System.IO to read it from disk, and then use Json.Net to deserialize it.
https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/file-system/how-to-read-from-a-text-file
https://www.newtonsoft.com/json

How to customize the color of custom syntax tokens in VSCode extension

TLDR; How can I have an extension colorize the syntax the extension is defining without it actually being a color theme the user has to enable?
I'm attempting to port this Sublime Text plugin (ToDone) to VSCode.
It creates a grammar for todo lists and then uses syntax highlighting to emphasize important tasks, mute completed tasks, etc.
I found "editor.tokenColorCustomizations", via Customize a Color Theme. It works with the new syntax when I use it in my user settings, but fails when I use it in the package.json#contributes portion of the extension manifest.
{
"contributes": {
"languages": [
{
"id": "todone",
"aliases": [
"ToDone",
"To-Done"
],
"extensions": [
".todone",
".todo"
]
}
],
"grammars": [
{
"language": "todone",
"scopeName": "text.todone",
"path": "./todone.tmLanguage"
}
],
"configurationDefaults": {
"[todone]": {
"editor.insertSpaces": false,
"editor.tokenColorCustomizations": {
"textMateRules": [
{
"scope": "symbol.definition.task-heading.todone",
"settings": {
"foreground": "#ff8800"
}
}
]
}
}
}
}
}
So far, the syntax seems ok — it's exactly what is being used by the Sublime plugin and the colors from the user-settings are applied correctly. Also, the format of the settings seems ok because "editor.insertSpaces" is being applied and the colors are working when present in the user-settings.
Lastly, I get a very disappointing 'Warning' 'Unknown editor configuration setting' message on the "editor.tokenColorCustomizations" setting in the extension package.json.
So, sounds like this setting is not enabled for extensions?
Another possible route I saw was to use decorators. But, I didn't see anything on inspecting the syntax tokens associated with a portion of text in the docs, e.g. some way to iterate through the syntax tokens of the document to apply decorators. So, the decorator route sounds like the hard-way compared to "editor.tokenColorCustomizations".
Any suggestions on how to make this work would be greatly appreciated.
Edit: The code, so far, is on GitHub: tiffon/vscode-todone
It only fails if you specify a specific language. It is working for me if I do not specify the todone extension.
"configurationDefaults": {
"editor.insertSpaces": false,
"editor.tokenColorCustomizations": {
"textMateRules": [
{
"scope": "symbol.definition.task-heading.todone",
"settings": {
"foreground": "#ff8800"
}
}
]
}
}

Duplicated mapping key in serverless.yml

I'm using Serverless to deploy a couple of functions written in C# to AWS.
While deploying a message duplicated mapping key in "...\serverless.yml" is thrown.
Separately, both functions get deployed but when put together the said error message is shown.
What am I missing?
{
"service": "serverlessquick",
"provider": {
"name": "aws",
"runtime": "nodejs4.3"
},
"functions": {
"hello": {
"handler": "handler.hello",
"events": [
{
"http": {
"path": "hello",
"method": "get"
}
}
]
}
}
}
Make your yaml code into json this way any mistakes are obvious, and will be more likely to be picked up by the parser. If anyone comes across this, use the referenced config above.
I got a similar error but in my case it was indentation problem. Go through your YML file and see if the changes you have made have the correct identation. A json parser as mention by others can help narrow down where in the YML file the problem exists

EMR configuration json

According to http://docs.aws.amazon.com/cli/latest/reference/emr/create-cluster.html# the new EMR release, 4.0.0, allows for a configuration json file to configure components. Also looking at http://docs.aws.amazon.com//ElasticMapReduce/latest/ReleaseGuide/emr-configure-apps.html, I have the json structured:
[
{
"Classification": "mapred-site",
"Properties": {
"mapreduce.map.memory.mb": "4096",
"mapreduce.map.java.opts": "-Xmx4096M"
}
},
{
"Classification": "hadoop-env",
"Properties": {},
"Configurations": [
{
"Classification": "export",
"Properties": {
"HADOOP_CLIENT_OPTS": "-Xmx4096M"
}
}
]
}
]
The Hadoop env property works, but the mapred-site properties are not reflected when a create an EMR cluster. I can always set these properties from Hive, but any ideas how to make it work with configuration file?
I experienced a similar issue, but with the "hadoop-env" classification.
From this post: https://github.com/aws/aws-cli/issues/1502
I found that making the keywords (Classification, Properties, ...) lower case solved the problem.
Note: I am using AWS console, not CLI.

Resources