Giter Site home page Giter Site logo

file-stamped's Introduction

NAME

File::Stamped - time stamped log file

SYNOPSIS

use File::Stamped;
my $fh = File::Stamped->new(pattern => '/var/log/myapp.log.%Y%m%d.txt');
$fh->print("OK\n");

# with Log::Minimal
use Log::Minimal;
my $fh = File::Stamped->new(pattern => '/var/log/myapp.log.%Y%m%d.txt');
local $Log::Minimal::PRINT = sub {
    my ( $time, $type, $message, $trace) = @_;
    print {$fh} "$time [$type] $message at $trace\n";
};

DESCRIPTION

File::Stamped is utility library for logging. File::Stamped object mimic file handle.

You can use "myapp.log.%Y%m%d.log" style log file.

METHODS

  • my $fh = File::Stamped->new(%args);

    This method creates new instance of File::Stamped. The arguments are followings.

    You need to specify one of pattern or callback.

    • pattern : Str

      This is file name pattern. It is the pattern for filename. The format is POSIX::strftime(), see also POSIX.

    • callback : CodeRef

      You can use a CodeRef to generate file name.

      File::Stamped pass only one arguments to callback function.

      Here is a example code:

        my $pattern = '/path/to/myapp.log.%Y%m%d.log';
        my $f = File::Stamped->new(callback => sub {
            my $file_stamped = shift;
            local $_ = $pattern;
            s/!!/$$/ge;
            $_ = POSIX::strftime($_, localtime());
            return $_;
        });
      
    • close_after_write : Bool

      Default value is 1.

    • iomode: Str

      This is IO mode for opening file.

      Default value is '>>:utf8'. However, for perl-5.30 compatibility, '>>:raw' is used for syswrite.

    • autoflush: Bool

      This attribute changes $|.

    • rotationtime: Int

      The time between log file generates in seconds. Default value is 1.

    • auto_make_dir: Bool

      If this attribute is true, auto make directry of log file. Default value is false.

    • symlink: Str

      generate symlink file for log file.

  • $fh->print($str: Str)

    This method prints the $str to the file.

  • $fh->syswrite($str: Str [, $len: Int, $offset: Int])

    This method prints the $str to the file. This method uses syswrite internally. Writing is not buffered.

AUTHOR

Tokuhiro Matsuno <tokuhirom AAJKLFJEF@ gmail.com>

SEE ALSO

Log::Dispatch::File::Stamped

LICENSE

Copyright (C) Tokuhiro Matsuno

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

file-stamped's People

Contributors

jkeenan avatar kan avatar kazeburo avatar tokuhirom avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

kazeburo kan jkeenan

file-stamped's Issues

Metadata should use 'https' rather than 'ssh' to generate links

Today I went to investigate CPAN ticket 127361, which reports breakage in File::Stamped. I first went to your metacpan.org page. As I customarily do, right-clicked on the "Repository" link. For CPAN distributions whose source code is housed on github.com, that usually brings up a series of links to that web site. In the case of File-Stamped, however, the "Repository" link was:

ssh://[email protected]/tokuhirom/File-Stamped

Right-clicking (in Firefox, in this case) did not take me directly to your github page. Instead, it caused a box to pop up stating "This link needs to be opened with an application" and prompting me to select an application.

When I was eventually able to fork your repository and examine your code, I found this in META.json:

   "resources" : {
      "bugtracker" : {
         "web" : "ssh://[email protected]/tokuhirom/File-Stamped/issues"
      },
      "homepage" : "ssh://[email protected]/tokuhirom/File-Stamped",
      "repository" : {
         "url" : "ssh://[email protected]/tokuhirom/File-Stamped.git",
         "web" : "ssh://[email protected]/tokuhirom/File-Stamped"
      }
   },

The use of ssh://[email protected]/... here may be valid, but in my experience it is non-standard and sub-optimal. At the very least, it means that when a user clicks on the "Issues" link on your metacpan.org page, the user is taken to rt.cpan.org rather than to the '/issues' page on your github.com page.

I don't use Minilla, so I don't know exactly where to make corrections in your source code. But I suspect what you should be using is something like this:

   "resources" : {
      "bugtracker" : {
         "web" : "https://github.com/tokuhirom/File-Stamped/issues"
      },
      "homepage" : "https://github.com/tokuhirom/File-Stamped",
      "repository" : {
         "type" : "git",
         "url" : "https://github.com/tokuhirom/File-Stamped.git",
         "web" : "https://github.com/tokuhirom/File-Stamped"
      }
   },

Thank you very much.
Jim Keenan

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.