Log::Agent::File::Native - low-overhead IO::File


Log-Agent documentation Contained in the Log-Agent distribution.

Index


Code Index:

NAME

Top

Log::Agent::File::Native - low-overhead IO::File

SYNOPSIS

Top

 require Log::Agent::File::Native;

 my $fh = Log::Agent::File::Native->make(\*main::STDERR);

DESCRIPTION

Top

This class is a stripped down implementation of IO::File, to avoid using the IO::* hierarchy which does not work properly for my simple needs.

make glob

This is the creation routine. Encapsulates the glob reference so that we can use object-oriented calls on it.

Prints args to the file.

AUTHOR

Top

Raphael Manfredi <Raphael_Manfredi@pobox.com>

SEE ALSO

Top

Log::Agent::File::Rotate(3), Log::Agent::Driver::File(3).


Log-Agent documentation Contained in the Log-Agent distribution.

#
# $Id: Native.pm,v 1.1 2002/03/09 16:08:16 wendigo Exp $
#
#  Copyright (c) 1999, Raphael Manfredi
#  
#  You may redistribute only under the terms of the Artistic License,
#  as specified in the README file that comes with the distribution.
#  
# HISTORY
# $Log: Native.pm,v $
# Revision 1.1  2002/03/09 16:08:16  wendigo
# New maintainer
#
# Revision 0.2.1.2  2001/03/31 10:01:17  ram
# patch7: fixed =over to add explicit indent level
#
# Revision 0.2.1.1  2000/11/12 14:46:40  ram
# patch1: reset $\ before printing
#
# Revision 0.2  2000/11/06 19:30:33  ram
# Baseline for second Alpha release.
#
# $EndLog$
#

use strict;

########################################################################
package Log::Agent::File::Native;

#
# A native Perl filehandle.
#
# I'm no longer using the IO::* hierarchy because it is not adapted
# to what we're trying to achieve here.
#

#
# ->make
#
# Creation routine.
# Turns on autoflush as a side effect.
#
sub make {
	my $class = shift;
	my ($glob) = @_;
	select((select($glob), $| = 1)[0]);		# autoflush turned on
	return bless $glob, $class;
}

#
# ->print
#
# Print to file, propagates print() status.
#
sub print {
	my $glob = shift;
	local $\ = undef;
	return CORE::print $glob @_;
}

#
# ->close
#
# Close file.
#
sub close {
	my $glob = shift;
	CORE::close $glob;
}

#
# ->DESTROY
#
sub DESTROY {
	my $glob = shift;
	CORE::close $glob;
}

1;	# for require
__END__