root/lang/perl/Morris/trunk/lib/Morris/Plugin/Channel/Log/File.pm @ 19333

Revision 19333, 0.8 kB (checked in by daisuke, 5 years ago)

とりあえずログ取ったりできるようになった

  • Property svn:keywords set to Id
Line 
1# $Id$
2
3package Morris::Plugin::Channel::Log::File;
4use Moose;
5use MooseX::Types::Path::Class qw(Dir File);
6use File::Spec;
7
8with 'Morris::Plugin::Channel::Log::Handle';
9
10has 'directory' => (
11    is       => 'rw',
12    isa      => Dir,
13    required => 1,
14    coerce   => 1,
15    builder  => 'build_dir',
16    lazy     => 1
17);
18
19has 'file' => (
20    is       => 'rw',
21    isa      => File,
22    required => 1,
23    coerce   => 1,
24    builder  => 'build_file',
25    lazy     => 1
26);
27
28__PACKAGE__->meta->make_immutable;
29
30no Moose;
31
32sub build_dir {
33    return Path::Class::Dir->new(File::Spec->tmpdir);
34}
35
36sub build_file {
37    my $self = shift;
38    my $file = $self->directory->file(
39        sprintf( '%s.log', $self->channel ) );
40    return $file;
41}
42
43sub build_handle {
44    my $self = shift;
45    my $fh   =  $self->file->open('a');
46    $fh->autoflush(1);
47    return $fh;
48}
49
501;
Note: See TracBrowser for help on using the browser.