Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/moznion/p5-test-fluent-logger
A mock implementation of Fluent::Logger for testing
https://github.com/moznion/p5-test-fluent-logger
fluentd perl testing
Last synced: about 1 month ago
JSON representation
A mock implementation of Fluent::Logger for testing
- Host: GitHub
- URL: https://github.com/moznion/p5-test-fluent-logger
- Owner: moznion
- License: other
- Created: 2017-01-24T17:46:45.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-06-13T04:10:24.000Z (over 7 years ago)
- Last Synced: 2024-11-06T00:04:06.184Z (3 months ago)
- Topics: fluentd, perl, testing
- Language: Perl
- Homepage: https://metacpan.org/pod/Test::Fluent::Logger
- Size: 16.6 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: Changes
- License: LICENSE
Awesome Lists containing this project
README
[![Build Status](https://travis-ci.org/moznion/p5-Test-Fluent-Logger.svg?branch=master)](https://travis-ci.org/moznion/p5-Test-Fluent-Logger)
# NAMETest::Fluent::Logger - A mock implementation of Fluent::Logger for testing
# SYNOPSIS
use Test::More;
use Test::Fluent::Logger; # Enable the function of this library just by using
# (Activate intercepting the fluentd log payload)use Fluent::Logger;
my $logger = Fluent::Logger->new(
host => '127.0.0.1',
port => 24224,
tag_prefix => 'prefix',
);$logger->post("tag1", {foo => 'bar'}); # Don't post to fluentd, it puts the log content on internal stack
$logger->post("tag2", {buz => 'qux'}); # ↑Either# Get internal stack (array)
my @fluent_logs = get_fluent_logs;
is_deeply \@fluent_logs, [
{
'tag_prefix' => 'prefix',
'time' => '1485443191.94598',
'message' => {
'foo' => 'bar'
}
},
{
'tag_prefix' => 'prefix',
'time' => '1485443191.94599',
'message' => {
'buz' => 'qux'
}
}
];# Clear internal stack (array)
clear_fluent_logs;@fluent_logs = get_fluent_logs;
is_deeply \@fluent_logs, [];# DESCRIPTION
Test::Fluent::Logger is a mock implementation of Fluent::Logger for testing.
This library intercepts the log payload of fluentd and puts that on stack.
You can pickup log\[s\] from stack and it can be used to testing.# FUNCTIONS
## `get_fluent_logs(): Array[HashRef]`
Get fluentd logs from stack as array.
Item of the array is hash reference. The hash reference is according to following format;
{
'tag_prefix' => 'prefix',
'time' => '1485443191.94599', # <= timestamp
'message' => {
'buz' => 'qux'
}
}## `clear_fluent_logs()`
Clear stack of fluentd logs.
## `activate()`
Activate intercepting the log payload.
## `deactivate()`
Deactivate intercepting the log payload.
# SEE ALSO
- [Fluent::Logger](https://metacpan.org/pod/Fluent::Logger)
# LICENSE
Copyright (C) moznion.
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.# AUTHOR
moznion