Include information from file name (Tag) in output - fluent-bit

Using the 'tail' input plugin I'd like to include information from the filename into the message. I can parse the filename (from the tag) and modify it, but not able to include any info from it in the (stdout) output.

Specifying a Path_Key to tail will add the file name to the record. The parser filter can be used to extract information as individual fields.

Related

How to use meta-data for translated strings with lupdate?

The Qt documentation advertises the following syntax to add meta-data to translated strings.
An alternative way to attach meta-data is to use the following syntax:
//~ <field name> <field contents>
This can be used to attach meta-data to the message. The field name should consist of a domain prefix (possibly the conventional file extension of the file format the field is inspired by), a hyphen and the actual field name in underscore-delimited notation. For storage in TS files, the field name together with the prefix "extra-" will form an XML element name. The field contents will be XML-escaped, but otherwise appear verbatim as the element's contents. Any number of unique fields can be added to each message.
Example:
//: This is a comment for the translator.
//= qtn_foo_bar
//~ loc-layout_id foo_dialog
//~ loc-blank False
//~ magic-stuff This might mean something magic.
QString text = MyMagicClass::tr("Sim sala bim.");
Even when I copy the special comments verbatim into the source code, the <extracomment> appears in the .ts file, and the id is added as <message id="qtn_foo_bar">.
As for the meta-data, I would expect new entries in the .ts file, e. g. <extra-loc-layout_id>foo_dialog</extra-loc-layout_id>, but the meta-data doesn't appear at all.
How do I make this work?

Best practice to parse multiple config files

What would be the best practice - if there is any - to parse multiple config files?
I want to parse the mysql server configuration and also write the configuration again.
The configuration allows to issue multiple lines like:
!includedir /etc/mysql.d/
So the interesting thing is, that some configuration may be located in the main file but other may be located in a sub file.
I think pyparsing only works on ONE single file or one content string.
So I probably first need to read all files and maybe restructures the contents like adding headers for the different files...
====main file====
[mysql]
....
!includedir /etc/mysql.d/
====/etc/mysql.d/my.cnf====
[client]
.....
I would only have one pyparsing call.
Then I could parse everything into one big data object, group the file sections and have the file names as keys. This way I could also write the data back to the disk...
The other possibility would be to parse the main file and programmatically parse all other files that were found in the main file.
Thus I would have several pyparsing calls.
What do you think?
In your pyparsing code, attach a parse action to the expression that matches the include statements, have it parse the contents of the referenced files or directory of files, then merge those results into the current parse output. The parse action would make the successive calls to parseString, your code would only make a single call.
See this new example added to the pyparsing examples directory: https://github.com/pyparsing/pyparsing/blob/master/examples/include_preprocessor.py

in PMCMD command can we pass source and target tables names

need to run a workflow where the session has source and target variables which will be feeded the value through PMCMD command.is it possible
You cannot directly pass the source and target table names, but you can parameterize those names and put those in parameter file. Then you can pass the parameter file path in pmcmd.
You cannot have source and target names in PMCMD command
Instead create a parameter file and provide the source and target names using the
parameter identifiers like $DBConnection_Src= and $DBConnection_Tgt=
Have below format,
[Folder_Naem.WF:Workflow_Name.ST:SessionName]
$DBConnection_Src=Source_Name
$DBConnection_Tgt=Target_Name
Create this parameter file and provide the path and file name,
In the mapping tab for source and target provide the parameters specified in the parameter file
Parameter file is very helpful for dynamic parameter changes. You can edit the parameter file rather than making changes in the informatica workflow

How to Set a File's Blob Filename?

In a Plone's File content type, which property stores the file's original filename?
I'm using plone.jsonapi.routes to upload files to a plone instance. I can set the id ant the title but I can't set the associated file's filename.
For example, when I upload a file to Plone in the regular way, I can set its id and title, but additionally to that, the original file name is stored somewhere. You can see it here:
objects-essay.pdf - PDF document indicates the name the original file has.
But when I upload it with plone.jsonapi.routes that field is empty. So, I'm trying to figure it out which property stores the name to pass it to the api or to set it by hand.
Thanks.
IIRC, all Archetypes-based content types have a setFilename method that you can use to do this.
On Dexterity-based content types file's content is stored in blobs in the ZODB (instances of NamedBlobFile) and there's a parameter named filename that you can use to set it.
You can see an example of the later in plone.app.contenttypes.

Getting extension of the file in FileUpload Control

At the moment i get file extension of the file like :
string fileExt = System.IO.Path.GetExtension(filUpload.FileName);
But if the user change the file extension of the file ( for example user could rename "test.txt" to "test.jpg" ), I can't get the real extension . What's the solution ?
You seem to be asking if you can identify file-type from its content.
Most solutions will indeed attempt the file extension, but there are too many different possible file types to be reliably identifiable.
Most approaches use the first several bytes of the file to determine what they are.
Here is one list, here another.
If you are only worried about text vs binary, see this SO question and answers.
See this SO answer for checking if a file is a JPG - this approach can be extended to use other file headers as in the first two links in this answer.
Whatever the user renames the file extension to, that is the real file extension.
You should never depend on the file extension to tell you what's in the file, since it can be renamed.
See "how can we check file types before uploading them in asp.net?"
There's no way to get the 'real' file extension - the file extension that you get from the filename is the real one. If file content is your concern, you can retrieve the content type using the .ContentType property and verify that it is a content type that you are expecting - eg. image/jpg.

Resources