1667388120
NAME
Fluent::Logger - A structured event logger for Fluent
SYNOPSIS
use Fluent::Logger;
my $logger = Fluent::Logger->new(
host => '127.0.0.1',
port => 24224,
);
$logger->post("myapp.access", { "agent" => "foo" });
# output: myapp.access {"agent":"foo"}
my $logger = Fluent::Logger->new(
tag_prefix => 'myapp',
host => '127.0.0.1',
port => 24224,
);
$logger->post("access", { "agent" => "foo" });
# output: myapp.access {"agent":"foo"}
DESCRIPTION
Fluent::Logger is a structured event logger for Fluentd.
METHODS
new(%args)
create new logger instance.
%args:
tag_prefix => 'Str': optional
host => 'Str': default is '127.0.0.1'
port => 'Int': default is 24224
timeout => 'Num': default is 3.0
socket => 'Str': default undef (e.g. "/var/run/fluent/fluent.sock")
prefer_integer => 'Bool': default 1 (set to Data::MessagePack->prefer_integer)
event_time => 'Bool': default 0 (timestamp includes nanoseconds, supported by fluentd >= 0.14.0)
buffer_limit => 'Int': defualt 8388608 (8MB)
buffer_overflow_handler => 'Code': optional
truncate_buffer_at_overflow => 'Bool': default 0
ack => 'Bool': default 0 (not works on MSWin32)
retry_immediately => 'Int': default 0 (retries immediately N times on error occured)
buffer_overflow_handler
You can inject your own custom coderef to handle buffer overflow in the event of connection failure. This will mitigate the loss of data instead of simply throwing data away.
Your proc should accept a single argument, which will be the internal buffer of messages from the logger. This coderef is also called when logger.close() failed to flush the remaining internal buffer of messages. A typical use-case for this would be writing to disk or possibly writing to Redis.
truncate_buffer_at_overflow
When truncate_buffer_at_overflow is true and pending buffer size is larger than buffer_limit, post() returns undef.
Pending buffer still be kept, but last message passed to post() is not sent and not appended to buffer. You may handle the message by other method.
ack
post() waits ack response from server for each messages.
An exception will raise if ack is miss match or timed out.
This option does not work on MSWin32 platform currently, because Data::MessagePack::Stream does not work.
retry_immediately
By default, Fluent::Logger will retry to send the buffer at next post() called when an error occured in post().
If retry_immediately(N) is set, retries immediately max N times.
post($tag:Str, $msg:HashRef)
Send message to fluent server with tag.
Return bytes length of written messages.
If event_time is set to true, log's timestamp includes nanoseconds.
post_with_time($tag:Str, $msg:HashRef, $time:Int|Float)
Send message to fluent server with tag and time.
If event_time is set to true, $time argument accepts Float value (such as Time::HiRes::time()).
close()
close connection.
If the logger has pending data, flushing it to server on close.
errstr
return error message.
$logger->post( info => { "msg": "test" } )
or die $logger->errstr;
AUTHOR
HIROSE Masaaki <hirose31 _at_ gmail.com>
Shinichiro Sei <sei _at_ kayac.com>
FUJIWARA Shunichiro <fujiwara _at_ cpan.org>
THANKS TO
Kazuki Ohta
FURUHASHI Sadayuki
lestrrat
REPOSITORY
https://github.com/fluent/fluent-logger-perl
git clone git://github.com/fluent/fluent-logger-perl.git
patches and collaborators are welcome.
SEE ALSO
COPYRIGHT & LICENSE
Copyright FUJIWARA Shunichiro
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Author: fluent
Source Code: https://github.com/fluent/fluent-logger-perl
License: View license
1667388120
NAME
Fluent::Logger - A structured event logger for Fluent
SYNOPSIS
use Fluent::Logger;
my $logger = Fluent::Logger->new(
host => '127.0.0.1',
port => 24224,
);
$logger->post("myapp.access", { "agent" => "foo" });
# output: myapp.access {"agent":"foo"}
my $logger = Fluent::Logger->new(
tag_prefix => 'myapp',
host => '127.0.0.1',
port => 24224,
);
$logger->post("access", { "agent" => "foo" });
# output: myapp.access {"agent":"foo"}
DESCRIPTION
Fluent::Logger is a structured event logger for Fluentd.
METHODS
new(%args)
create new logger instance.
%args:
tag_prefix => 'Str': optional
host => 'Str': default is '127.0.0.1'
port => 'Int': default is 24224
timeout => 'Num': default is 3.0
socket => 'Str': default undef (e.g. "/var/run/fluent/fluent.sock")
prefer_integer => 'Bool': default 1 (set to Data::MessagePack->prefer_integer)
event_time => 'Bool': default 0 (timestamp includes nanoseconds, supported by fluentd >= 0.14.0)
buffer_limit => 'Int': defualt 8388608 (8MB)
buffer_overflow_handler => 'Code': optional
truncate_buffer_at_overflow => 'Bool': default 0
ack => 'Bool': default 0 (not works on MSWin32)
retry_immediately => 'Int': default 0 (retries immediately N times on error occured)
buffer_overflow_handler
You can inject your own custom coderef to handle buffer overflow in the event of connection failure. This will mitigate the loss of data instead of simply throwing data away.
Your proc should accept a single argument, which will be the internal buffer of messages from the logger. This coderef is also called when logger.close() failed to flush the remaining internal buffer of messages. A typical use-case for this would be writing to disk or possibly writing to Redis.
truncate_buffer_at_overflow
When truncate_buffer_at_overflow is true and pending buffer size is larger than buffer_limit, post() returns undef.
Pending buffer still be kept, but last message passed to post() is not sent and not appended to buffer. You may handle the message by other method.
ack
post() waits ack response from server for each messages.
An exception will raise if ack is miss match or timed out.
This option does not work on MSWin32 platform currently, because Data::MessagePack::Stream does not work.
retry_immediately
By default, Fluent::Logger will retry to send the buffer at next post() called when an error occured in post().
If retry_immediately(N) is set, retries immediately max N times.
post($tag:Str, $msg:HashRef)
Send message to fluent server with tag.
Return bytes length of written messages.
If event_time is set to true, log's timestamp includes nanoseconds.
post_with_time($tag:Str, $msg:HashRef, $time:Int|Float)
Send message to fluent server with tag and time.
If event_time is set to true, $time argument accepts Float value (such as Time::HiRes::time()).
close()
close connection.
If the logger has pending data, flushing it to server on close.
errstr
return error message.
$logger->post( info => { "msg": "test" } )
or die $logger->errstr;
AUTHOR
HIROSE Masaaki <hirose31 _at_ gmail.com>
Shinichiro Sei <sei _at_ kayac.com>
FUJIWARA Shunichiro <fujiwara _at_ cpan.org>
THANKS TO
Kazuki Ohta
FURUHASHI Sadayuki
lestrrat
REPOSITORY
https://github.com/fluent/fluent-logger-perl
git clone git://github.com/fluent/fluent-logger-perl.git
patches and collaborators are welcome.
SEE ALSO
COPYRIGHT & LICENSE
Copyright FUJIWARA Shunichiro
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Author: fluent
Source Code: https://github.com/fluent/fluent-logger-perl
License: View license
1667619300
Perl 5 Cucumber
This is a minimal implementation of Cucumber in Perl5
To learn about Cucumber take a look at:
http://wiki.gihub.com/aslakhellesoy/cucumber
Feature: Dealing with mushrooms
In order to test the effect of evil poisonous mushrooms
As an evil scientist
I want to test effects of eating mushrooms on little children
Scenario: Mushrooms are bad for you, they kill boys
Given a live boy in a forest
When he ate a mushroom
Then he was a dead boy in a forest
Scenario: Mushrooms are bad for girls too
Given a live girl in a forest
When she ate a mushroom
Then she was a dead girl in a forest
Given qr/(.*) in (.*)/, sub {
my ($description,$location) = @_;
$state{human} = $description;
$state{location} = $location;
};
When qr/s?he ate (.*)/, sub {
my $item = shift;
if ($item eq 'a mushroom') {
$state{human} =~ s/live/dead/;
}
};
Then qr/s?he was (.*) in (.*)/, sub {
my ($description,$location) = @_;
is($state{human},$description,$description);
is($state{location},$location,$location);
};
$ perl p5-cucumber.pl
Feature: Dealing with mushrooms
In order to test the effect of evil poisonous mushrooms
As an evil scientist
I want to test effects of eating mushrooms on little children
Scenario: Mushrooms are bad for you, they kill boys
Given a live boy in a forest
When he ate a mushroom
Then he was a dead boy in a forest
ok 1 - a dead boy
ok 2 - a forest
Scenario: Mushrooms are bad for girls too
Given a live girl in a forest
When she ate a mushroom
Then she was a dead girl in the sea
ok 3 - a dead girl
not ok 4 - the sea
# Failed test 'the sea'
# at ./p5-cucumber.pl line 82.
# got: 'a forest'
# expected: 'the sea'
1..4
# Looks like you failed 1 test of 4.
(exitcode is 1 for failure)
And when we fix the story:
$ perl p5-cucumber.pl
Feature: Dealing with mushrooms
In order to test the effect of evil poisonous mushrooms
As an evil scientist
I want to test effects of eating mushrooms on little children
Scenario: Mushrooms are bad for you, they kill boys
Given a live boy in a forest
When he ate a mushroom
Then he was a dead boy in a forest
ok 1 - a dead boy
ok 2 - a forest
Scenario: Mushrooms are bad for girls too
Given a live girl in a forest
When she ate a mushroom
Then she was a dead girl in a forest
ok 3 - a dead girl
ok 4 - a forest
1..4
(exitcode is 0 for success)
Great thank you for the perl-il and perl-qa mailing lists
for helping me with some high level perl concepts that make
this code so beautiful like it is.
Another huge thank you to the people in #perl @freenode.net
who helped me with sticky dereferencing and scalar/list
problems.
Author: kesor
Source Code: https://github.com/kesor/p5-cucumber
1621103940
Continuing on the Quick Revision of Important Questions for My Interviews. These Are Good Puzzles or Questions Related to Data Structures.
My Article Series on Algorithms and Data Structures in a Sort of ‘Programming Language Agnostic Way’. Few of the Algorithms and Data Structures in C, Few in C++, and Others in Core Java. Assorted Collection for Learning, Revising, Revisiting, Quick Refresh, and a Quick Glance for Interviews. You May Even Include them Directly for Professional or Open Source Efforts. Have Included Explanation Only for Few of These! Hope these turn out to be Really Helpful as per the Author’s Intention.
#java #core java #data structures #dijkstra #core java basics #data structure using java #algorithms and data structures #java code examples #linked list in java #circular linked list
1617373031
Fluent Bit is an open source Log Processor and Forwarder which allows you to collect any data like metrics and logs from different sources, enrich them with filters and send them to multiple destinations. It’s the preferred choice for containerized environments like Kubernetes.
Fluent Bit is a CNCF (Cloud Native Computing Foundation) subproject under the umbrella of Fluentd.
► This video was sponsored by CNCF - https://www.cncf.io/ 🙌🏼
► More infos on Fluent Bit: https://fluentbit.io/
#fluent #kubernetes
1622000417
Welcome to the introduction to data structures tutorial. Have you ever used a DVD case to store multiple DVDs or even a simple register used to store data manually? Both of the above real-life examples are a form of data structures.
Here DVDs in a DVD case and records in the register are examples of data and their arrangement in a particular structure makes them more easily accessible. Combining a similar concept with the digital world gives us data structures in computers.
A set of data in mathematics might be unchanging but in computers, they can grow, shrink or change with the use of algorithms. These are dynamic sets.
A data structure is a specific way of arranging the data in a computer so that its usage is more effective and efficient.
Here are a few standard terms that we will be using frequently in our Data Structure’s learning journey:
1. Data: Data is the elementary value or we can also say that it is a collection of values. For example, employee name and employee ID are data about an employee.
2. Group Item: Data items having sub-data items are known as group items. For example, names. I can have the first name and surname of the employee.
3. Record: Record is the collection of various data items. For example in the case of employee data, the record might consist of name, address, designation, pay scale, and working hours.
4. File: A file is a collection of multiple records of the same entity. For example, a collection of 500 employee records is a file.
5. Entity: Entity is a class of certain objects. Each entity has various attributes.
6. Attribute: Each attribute represents a particular property of the entity.
7. Field: Field is an elementary unit of the information that represents the attribute of an entity.
There are 2 types of data structures:
A primitive data structure or data type is defined by a programming language and the type and size of the variables, values are specific to the language. It does not have any additional methods. For example int, float, double, long, etc. These data types can hold a single value.
These data structures are defined by the programmers and not by the programming languages. These data structures can hold multiple values and make them easily accessible.
Non-primitive data structures can further be classified into two types:
In the linear data structure, as the name suggests, data elements are arranged sequentially or linearly where each element is in connection with its previous and next element.
Since a single level is involved in a linear data structure, therefore, the whole data structure is traversable through all the elements in a single run only. These data structures are easy to implement. For example array, linked list, stack, and queue.
In a non-linear data structure, the elements’ arrangement is not sequential or linear. Instead, they are arranged hierarchically. Hence we cannot traverse through each element in one run.
Non-linear data structures are a little bit more difficult to implement than linear data structures but they use computer memory more efficiently compared to linear data structures. For example graphs and trees.
Data structures classification can also be done in the following two categories :
Static data structures have a specific memory size, the allocation of which is done at the time of compilation. Therefore, these data structures have fix memory size.
An array is the best example of static data structure.
Dynamic data structures have flexible memory sizes since the memory allocation is done at the run time. Hence, dynamic data structures can shrink or grow as and when required by deallocating or allocating the memory respectively.
For example, linked lists, stack, queue, graphs, and trees are dynamic data structures.
#data structure tutorials #basics of data structures #introduction to data structures