Giter Site home page Giter Site logo

log-any-adapter-dupstd's People

Contributors

ivanych avatar manwar avatar

Watchers

 avatar  avatar

Forkers

manwar darviarush

log-any-adapter-dupstd's Issues

Bug: В лог сообщения выводятся через некоторое время

В https://github.com/ivanych/Log-Any-Adapter-Dupstd/blob/master/lib/Log/Any/Adapter/Duperr.pm дублируется STDERR, соответственно открывается новый файловый хандлер с буфером.

Решить эту проблему можно так:

my $oldout = select $self->{fh};
$|=1;
select $oldout;

или

$self->{fh}->autoflush(1);

как указано в документации к перловым хандлерам: https://metacpan.org/pod/IO::Handle

Alternative implementation of the Duperr adapter as an extension of the Stderr adapter

This

package Log::Any::Adapter::Duperr;

#
# Cunning adapter for logging to a duplicate of STDERR
#

use 5.008001;
use strict;
use warnings;

use parent qw( Log::Any::Adapter::Stderr );

use Carp qw( croak );

our $VERSION = '0.05';

{
    open my $fh, '>&', *STDERR or croak "Can't dup STDERR: $!";    ## no critic [InputOutput::RequireBriefOpen]

    foreach my $method (Log::Any::Adapter::Util::logging_methods) {
        my $parent_method = __PACKAGE__->can($method);
        no strict 'refs';                                          ## no critic (ProhibitNoStrict)
        *{$method} = sub {
            local *STDERR = $fh;
            $parent_method->(@_);
        };
    }
}

1;

is an alternative implementation of the Duperr adapter as an extension of the Stderr adapter. Unfortunately the implementation does not pass your unit tests because the tests are not implementation agnostic:

# irresponsible penetration into the object
my $adapter_fh = $log->{adapter}->{fh};

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.