From 896b7ac5cee14f69937ad01a8c099b992f560678 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Sat, 6 Feb 2021 19:34:55 +0800 Subject: [PATCH] Replaced the messy GNU-styled, multi-lingual documents with a single Markdown README.md. Added the GitHub repository to the document and removed the SourceForge website, my web page, and the SourceForge mailing list from the document. Removed the document license, and my PGP key from the package. Removed the signature file from the repository. Changed the license from GPLv3 to APLv2. Various fixes to avoid JetBrains IDE problem detection. --- AUTHORS | 1 - AUTHORS.zh-cn | 1 - AUTHORS.zh-tw | 1 - Build.PL | 4 +- COPYING | 674 ----------------------------- Changes | 72 ++-- INSTALL | 211 --------- INSTALL.zh-cn | 186 -------- INSTALL.zh-tw | 186 -------- LICENSE | 202 +++++++++ MANIFEST | 39 -- MANIFEST.SKIP | 14 + META.yml | 14 - Makefile.PL | 6 +- NEWS | 29 -- README | 67 --- README.md | 613 +++++++++++++++++++++++++++ README.zh-cn | 58 --- README.zh-tw | 58 --- SIGNATURE | 61 --- THANKS.zh-cn | 1 - THANKS.zh-tw | 1 - TODO | 2 - TODO.zh-cn | 1 - TODO.zh-tw | 1 - UPGRADE | 47 -- UPGRADE.zh-cn | 39 -- UPGRADE.zh-tw | 39 -- arclog | 906 +++++++++++++++++++-------------------- arclog.en.html | 506 ---------------------- arclog.zh-cn.html | 510 ---------------------- arclog.zh-tw.html | 515 ---------------------- fdl.txt | 397 ----------------- pgpkey.asc | 40 -- t/00-signature.t | 16 +- t/01-exhaust.t | 123 +++--- t/02-several.t | 211 +++++---- t/03-fallback.t | 203 +++++---- t/04-errors.t | 226 +++++----- t/_helper.pm | 1035 +++++++++++++++++++++++---------------------- 40 files changed, 2235 insertions(+), 5081 deletions(-) delete mode 100644 AUTHORS delete mode 100644 AUTHORS.zh-cn delete mode 100644 AUTHORS.zh-tw delete mode 100644 COPYING delete mode 100644 INSTALL delete mode 100644 INSTALL.zh-cn delete mode 100644 INSTALL.zh-tw create mode 100644 LICENSE delete mode 100644 MANIFEST create mode 100644 MANIFEST.SKIP delete mode 100644 META.yml delete mode 100644 NEWS delete mode 100644 README create mode 100644 README.md delete mode 100644 README.zh-cn delete mode 100644 README.zh-tw delete mode 100644 SIGNATURE delete mode 100644 THANKS.zh-cn delete mode 100644 THANKS.zh-tw delete mode 100644 TODO delete mode 100644 TODO.zh-cn delete mode 100644 TODO.zh-tw delete mode 100644 UPGRADE delete mode 100644 UPGRADE.zh-cn delete mode 100644 UPGRADE.zh-tw delete mode 100644 arclog.en.html delete mode 100644 arclog.zh-cn.html delete mode 100644 arclog.zh-tw.html delete mode 100644 fdl.txt delete mode 100644 pgpkey.asc diff --git a/AUTHORS b/AUTHORS deleted file mode 100644 index d6c1a2a..0000000 --- a/AUTHORS +++ /dev/null @@ -1 +0,0 @@ -imacat diff --git a/AUTHORS.zh-cn b/AUTHORS.zh-cn deleted file mode 100644 index 2e02909..0000000 --- a/AUTHORS.zh-cn +++ /dev/null @@ -1 +0,0 @@ -甡鎖癡 diff --git a/AUTHORS.zh-tw b/AUTHORS.zh-tw deleted file mode 100644 index 2ec7e15..0000000 --- a/AUTHORS.zh-tw +++ /dev/null @@ -1 +0,0 @@ -依瑪貓 diff --git a/Build.PL b/Build.PL index 8c04682..cce11f6 100755 --- a/Build.PL +++ b/Build.PL @@ -6,7 +6,7 @@ use Config qw(%Config); use Module::Build; # Check if there is any old file -use vars qw(%old_version); +our (%old_version); %old_version = qw(); foreach (qw(/usr/sbin/arclog.pl /usr/sbin/arclog @@ -52,7 +52,7 @@ my $build = Module::Build->new( dist_version_from => "arclog", dist_abstract => "Archive log files monthly", dist_author => "imacat ", - license => "gpl", + license => "apache_2_0", sign => 1, script_files => [ "arclog" ], diff --git a/COPYING b/COPYING deleted file mode 100644 index 94a9ed0..0000000 --- a/COPYING +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/Changes b/Changes index 8befd53..55650f6 100644 --- a/Changes +++ b/Changes @@ -1,19 +1,35 @@ arclog change log +2020-02-06 + 1. Replaced the messy GNU-styled, multi-lingual documents with a + single Markdown README.md. + 2. Added the GitHub repository to the document, and removed the + SourceForge website, my web page, and the SourceForge mailing + list from the document. + 3. Removed the document license, and my PGP key from the package. + Removed the signature file from the repository. + 4. Various fixes to avoid JetBrains IDE problem detection. + +2020-02-04 + Changed the license from GPLv3 to APLv2. + +2020-02-01 + arclog is hosted on GitHub now. + 2008-11-18 - 1. INSTALL and arclog.en.html: Fixed the grammer on + 1. INSTALL and arclog.en.html: Fixed the grammar on installation with the CPAN or CPANPLUS shell, changed "install with the CPAN shell using" and "install with the CPANPLUS shell using" to "install it with the CPAN shell by running" and "install it with the CPANPLUS shell by running". - 2. INSTALL* and ahping.*.html: Changed "Fedora/Red Hat" to + 2. INSTALL* and reslog.*.html: Changed "Fedora/Red Hat" to "Red Hat/Fedora/CentOS". 3. INSTALL.zh-tw and INSTALL.zh-cn: Added the missing Date::Parse to the required modules section. 2008-11-17 - 1. INSTALL and arclog.en.html: Fixed the grammer on required + 1. INSTALL and arclog.en.html: Fixed the grammar on required and optional module installation, changed "install using" and "install this using" to "install it by running". @@ -23,7 +39,7 @@ arclog change log in required modules. It is stated in the module description in detail now. 3. arclog.*.html: Fixed so that installation from source and - with shells are joint into one sentense. + with shells are joint into one sentence. 2008-11-12 1. INSTALL, arclog.en.html: Updated "don't" and "won't" to @@ -85,8 +101,8 @@ arclog change log _private::LogFile class. 2007-12-03 - 1. arclog.zh-tw.html, arclog.zh-cn.html: "不需要安裝新版" was - revised to "不需要昇級新版". + 1. arclog.zh-tw.html, arclog.zh-cn.html: "銝閬摰鋆啁" was + revised to "銝閬蝝啁". 2. Build.PL: Fixed the comment. This file is "Build.PL", not "Makefile.PL". 3. Build.PL: Added "use warnings;". @@ -95,14 +111,14 @@ arclog change log Documentation fix. 1. arclog, arclog.*.html, README*: Added the information on the usability of arclog with log files from many - softwares that log with an Apache-like log format. + software that log with an Apache-like log format. 2. arclog.zh-cn.html: Fixed the version number. 3. arclog.*.html: Added ... to the description. 2007-12-03 version 3.03 1. t/*.t: Fixed so that send frread($fs) instead of $cs is sent to arclog STDIN when reading from STDIN, so that - compresed content is sent to arclog but not the original + compressed content is sent to arclog but not the original content. 2. arclog.zh-tw.html, arclog.zh-cn.html: Revised the Chinese text on "3-argument open()" so that it is more readable. @@ -151,7 +167,7 @@ arclog change log 2007-11-29 1. arclog.zh-tw.html, TODO.zh-tw, TODO.zh-cn: Changed - '繁體中文' to '正體中文'. + '蝜擃銝剜' to '甇擃銝剜'. 2007-11-28 version 3.01 Test suite improvement. @@ -159,7 +175,7 @@ arclog change log 2. Makefile.PL: Use "use 5.008" instead of "use 5.8.0" for compatibility with older Perl. 3. t/01-exhaust.t: Added $vardump to error output, to catch - CPAN testers test failurs. + CPAN testers test failures. 4. Return to build distribution with ExtUtils::MakeMaker, since Module::Build did not preserve the original file date. @@ -300,8 +316,8 @@ arclog change log other packages can use it, too. 2. arclog: Added $one_arg in the parse_arg() subroutine to deal with only one argument, and check if the only one argument is STDIN in - advance. If a compressd source log file is the only one argument, - remove the compresssion suffix (.gz or .bz2) from the output + advance. If a compressed source log file is the only one argument, + remove the compression suffix (.gz or .bz2) from the output prefix. 3. _helper.pm: Added the cleanup() subroutine to clean up after a test. @@ -332,22 +348,22 @@ arclog change log 3. arclog: Reformatted the POD document. 4. arclog: Added the sort() method to the _private::Archive package, and implement the sorting ability. The new way (sort the - record index but not record themseves) seems to have lesser + record index but not record themselves) seems to have lesser memory impact than the original implementation. - 5. arclog: Added time zone to the bracked ISO 8601 format. + 5. arclog: Added time zone to the bracketed ISO 8601 format. 6. Upgrade notes changed from 2.1.1dev3 to 2.1.1dev4. 6. arclog: Rename the _private::Format::BracketISO package to _private::Format::ModfISO. It is not really ISO 8601. 2007-11-14 - 1. Changes.zh-tw, Changes.zh-cn: Removed. It is too troblesome to + 1. Changes.zh-tw, Changes.zh-cn: Removed. It is too troublesome to maintain 3 copies of the change log. 2. arclog: Fixed the rel2abs() subroutine and method so that it use getpwuid() instead of getlogin(), and respect the HOME environment variable for the current user. 3. arclog: Renamed the new_read() method as open_read(), the new_write() method as open_write(), the new_append() method - as open_append(). Replaced the strange architech that start + as open_append(). Replaced the strange architect that start a new instance with $ioclass, with reusing the same $io object. 4. arclog: Removed the Chinese GPL copyright message. There should only be one version of the copyright message, and should not be @@ -443,7 +459,7 @@ arclog change log 1. Reading loop changed from do {...} while() to for(;;;) {...}, to fix the problem "Exiting subroutine via next at ..." when - encounting and skipping a bad record. + encountering and skipping a bad record. 2003-01-04 1. File handler EOF read checks were fixed with @@ -536,12 +552,12 @@ arclog change log 2002-08-31 version 2.1.0dev1 Rewrite after almost 1 year, to be run on the newly-released Perl 5.8.0. - 1. Filehandles are now saved and passed in global + 1. File handles are now saved and passed in global named variables. This is the way it should be. The old way (initialize the file handles by duplicate the STDIN and assign them) was just not natural. It works in Perl 5.6.1, but not in - perl 5.8.0. The duplicated filehandles are + perl 5.8.0. The duplicated file handles are constants, which cannot be assigned new values. 2. Indents are changed from 1 tab to 4 columns, to accommodate the Perl style guide documented in @@ -603,7 +619,7 @@ arclog change log file is met, was fixed. 2. "none" keep mode was removed. "restart" and "delete" keep modes were added. - 3. Precheck on empty files was added. It bounces + 3. Pre-check on empty files was added. It bounces directly when an empty file is found in the first sight. 4. A bug that there's no documentation on --keep @@ -635,7 +651,7 @@ arclog change log 2001-06-11 version 1.5.1 1. A serious bug was fixed. :p I was planning to set - the memory limit dymatically but failed. And I + the memory limit dynamically but failed. And I forgot to return the original codes, which prevents the program from running. 2. The argument checking was modified to report @@ -685,7 +701,7 @@ arclog change log 3. "append" override mode was added. When the target archived file exists, it appends the records for that month to that file, for easy - merging on seperated log files. + merging on separated log files. 4. --sort option was added, to sort the records in a log file by time. 5. syslog log file format was supported. @@ -698,7 +714,7 @@ arclog change log overwrite. 1. Program flow was rewritten. The file open routine when open an archived file at the first - time was seperated, to insert handlers for + time was separated, to insert handlers for existing old archived files. 2. --override option was added, to set the override behavior when old archived files exist. @@ -708,7 +724,7 @@ arclog change log the temporary working files. 4. --compress option was added to set if we should compress the archived files. - 5. Checking on write previledge of the output + 5. Checking on write privilege of the output directory was added. 6. A bug that rel2abs will wrongly ignore the last part of a path when it is the current or parent @@ -727,7 +743,7 @@ arclog change log autoflush STDOUT solely under debugging mode. 2. Temporary working file method was removed. Works are done on the source file, to avoid the - garbages when program stopped in the middle. + garbage when program stopped in the middle. 3. File::Temp was introduced to handle the temporary working file. Records of this month was outputs to temporary file at first. @@ -735,7 +751,7 @@ arclog change log 5. "wb9" was introduced to zip with highest ratio. 6. Zipping size message was added. 7. format_number() was added to format the numbers. - 8. GNU copyright infomation was added. + 8. GNU copyright information was added. 9. Chinese annotations was added. 10. POD documents was added. 11. Release notes was added. @@ -748,7 +764,7 @@ arclog change log 2001-06-05 version 1.2.0 1. Program flow was rewritten. Now it outputs to the target file without gzipping first. Gzip - will be done next after finishing all outouts. + will be done next after finishing all outputs. 2. Message level was changed to $VERBOSE. 3. The default message level was changed to 1. The debugging message level was changed to 2. @@ -772,7 +788,7 @@ arclog change log arguments, in replace of my own argument-parsing routine. 5. File::Spec::Functions was introduced to handle - the pathnames, with my own rel2abs. + the pathname, with my own rel2abs. 6. Cwd was introduced to obtain the current working directory. diff --git a/INSTALL b/INSTALL deleted file mode 100644 index 5673721..0000000 --- a/INSTALL +++ /dev/null @@ -1,211 +0,0 @@ -arclog Installation Guide - -* Table of Contents - - * System Requirements - * Installation Instruction - ** Install with ExtUtils::MakeMaker - ** Install with Module::Build - - -* System Requirements - - 1. Perl, version 5.8.0 or above. arclog uses 3-argument open() to -duplicate filehandles, which is only supported since 5.8.0. I have -not successfully port this onto earlier versions yet. Please tell me -if you made it. You can run perl -v to see your current Perl version. -If you do not have Perl, or if you have an older version of Perl, you -can download and install/upgrade it from Perl website. - -http://www.perl.com/ - - If you are using MS-Windows, you can download and install -ActiveState ActivePerl. - -http://www.activestate.com/ - - 2. Required Perl modules: - - * Date::Parse - - This is used to parse the timestamp of the log records. - You can download and install Date::Parse from the CPAN archive - http://search.cpan.org/dist/TimeDate/ , - or install it with the CPAN shell by running "cpan Date::Parse", - or install it with the CPANPLUS shell by running - "cpanp i Date::Parse". - Debian/Ubandu Linux users can install it by running - "apt-get install libtimedate-perl". - Red Hat/Fedora/CentOS Linux users can install it by running - "yum install perl-TimeDate". - FreeBSD users can install it by running - "ports install p5-TimeDate". - ActivePerl users can install it by running - "ppm install Date::Parse". - - If you install arclog with the CPAN or CPANPLUS shell, the above - shall be automatically installed. - - 3. Optional Perl Modules - - * File::MMagic - - This is used to check the file type. If this is not - available, arclog will look for the file executable instead. - If that is not available, too, arclog will judge the file type - by its name suffix (extension). In that case arclog will fail - when reading from STDIN. - You can download and install File::MMagic from the CPAN archive - http://search.cpan.org/dist/File-MMagic/ , - or install it with the CPAN shell by running "cpan File::MMagic", - or install it with the CPANPLUS shell by running - "cpanp i File::MMagic". - Debian/Ubandu Linux users can install it by running - "apt-get install libfile-mmagic-perl". - Red Hat/Fedora/CentOS Linux users can install it by running - "yum install perl-File-MMagic". - FreeBSD users can install it by running - "ports install p5-File-MMagic". - ActivePerl MS-Windows users can install it by running - "ppm install File::MMagic". - The alternative file.exe for MS-Windows can be obtained from - the GnuWin32 home page: http://gnuwin32.sourceforge.net/. - Be sure to save it as file.exe somewhere in your PATH. - - It is preferred to use File::MMagic. The file executable - seems to make mistakes occationally. - - * Compress::Zlib - - This is used to support read/write of gzip compressed files. - It is only needed when gzip compressed files are encountered. - If it is not available when needed, arclog will try to use the - gzip executable instead. If that is not available, too, arclog - will fail. - You can download and install Compress::Zlib from the CPAN archive - http://search.cpan.org/dist/Compress-Zlib/ , - or install it with the CPAN shell by running "cpan Compress::Zlib", - or install it with the CPANPLUS shell by running - "cpanp i Compress::Zlib". - Debian/Ubandu Linux users can install it by running - "apt-get install libcompress-zlib-perl". - Red Hat/Fedora/CentOS Linux users can install it by running - "yum install perl-Compress-Zlib". - FreeBSD users can install it by running - "ports install p5-Compress-Zlib". - ActivePerl MS-Windows users can install it by running - "ppm install Compress::Zlib". - The alternative gzip.exe for MS-Windows can be obtained from - the gzip home page: http://www.gzip.org/. - Be sure to save it as gzip.exe somewhere in your PATH. - - * Compress::Bzip2, version 2 or above - - This is used to support read/write of bzip2 compressed - files. It is only needed when bzip2 compressed files are - encountered. If it is not available when needed, arclog will - try to use the bzip2 executable instead. If that is not - available, too, arclog will fail. Notice that older versions - before 2 does not work, since file I/O compression were not - implemented yet. - You can download and install Compress::Bzip2 from the CPAN archive - http://search.cpan.org/dist/Compress-Bzip2/ , - or install it with the CPAN shell by running "cpan Compress::Bzip2", - or install it with the CPANPLUS shell by running - "cpanp i Compress::Bzip2". - Debian/Ubandu Linux users can install it by running - "apt-get install libcompress-bzip2-perl". - Red Hat/Fedora/CentOS Linux users can install it by running - "yum install perl-Compress-Bzip2". - FreeBSD users can install it by running - "ports install p5-Compress-Bzip2". - ActivePerl MS-Windows users can install it by running - "ppm install Compress::Bzip2". - The alternative bzip2.exe for MS-Windows can be obtained from - the bzip2 home page: http://www.bzip.org/. - Be sure to save it as bzip2.exe somewhere in your PATH. - - * Term::ReadKey - - This is used to display the progress bar. Without this - arclog will not display the progress bar, but nothing else is - different. The progress bar is a good visual representation of - what arclog is currently doing. - You can download and install Term::ReadKey from the CPAN archive - http://search.cpan.org/dist/TermReadKey/ , - or install it with the CPAN shell by running "cpan Term::ReadKey", - or install it with the CPANPLUS shell by running - "cpanp i Term::ReadKey". - Debian/Ubandu Linux users can install it by running - "apt-get install libterm-readkey-perl". - Red Hat/Fedora/CentOS Linux users can install it by running - "yum install perl-TermReadKey". - FreeBSD users can install it by running - "ports install p5-Term-ReadKey". - ActivePerl MS-Windows users can install it by running - "ppm install Term::ReadKey". - - -* Installation Instruction - - If you are upgrading from arclog.pl 2.1.1dev4 or earlier, please -read UPGRADE for some upgrade instruction. - -** Install with ExtUtils::MakeMaker - - arclog uses standard Perl installation with ExtUtils::MakeMaker. -Follow these steps: - - % perl Makefile.PL - % make - % make test - % make install - - When running make install, make sure you have the priviledge to -write to the installation location. This usually requires the root -priviledge. - - If you are using ActivePerl under MS-Windows, you should use -nmake instead of make. nmake can be obtained from the Microsoft FTP -site. - -ftp://ftp.microsoft.com/Softlib/MSLFILES/nmake15.exe - - If you want to install into another location, you can set the -PREFIX. For example, to install into your home when you are not -root: - - % perl Makefile.PL PREFIX=/home/jessica - - Refer to the docuemntation of ExtUtils::MakeMaker for more -installation options (by running perldoc ExtUtils::MakeMaker). - - -** Install with Module::Build - - You can install with Module::Build instead, if you prefer. -Follow these steps: - - % perl Build.PL - % ./Build - % ./Build test - % ./Build install - - When running ./Build install, make sure you have the priviledge to -write to the installation location. This usually requires the root -priviledge. - - If you want to install into another location, you can set the ---prefix. For example, to install into your home when you are not -root: - - % perl Build.PL --prefix=/home/jessica - - Refer to the docuemntation of Module::Build for more -installation options (by running perldoc Module::Build). - - -imacat -2008-11-17 -imacat@mail.imacat.idv.tw -http://www.imacat.idv.tw/ diff --git a/INSTALL.zh-cn b/INSTALL.zh-cn deleted file mode 100644 index 28ddeda..0000000 --- a/INSTALL.zh-cn +++ /dev/null @@ -1,186 +0,0 @@ -arclog 假蚾硌鰍 - -♁醴翹 - - ♁炵苀剒⑴ - ♁假蚾硌鰍 - ♁♁眕 ExtUtils::MakeMaker 假蚾 - ♁♁眕 Module::Build 假蚾 - - -♁炵苀剒⑴ - - 1. Perl 5.8.0 麼眕奻﹝ arclog 妏蚚統杅腔 open() 眕葩秶紫偶紱釬ㄛ -扂遜祥眭耋崋繫蜊迡善載婌腔唳掛奻硒俴﹝蠙蒧奿堋鹹斯螂婌腔唳掛奻硒俴ㄛ -③豢咂扂﹝斕褫眕怀 perl -v 脤戙斕醴ヶ腔 Perl 唳掛﹝醴ヶ湮嗣杅腔 Unix -炵苀飲衄 Perl ﹝蝜斕羶衄 Perl 麼剒猁汔撰ㄛ褫眕善 Perl 厙桴狟婥假蚾郔 -陔唳 Perl ﹝ - - http://www.perl.com/ - - 蠙蒑 MS-Windows ㄛ褫眕狟婥假蚾 ActiveState 鼠侗腔 ActivePerl ﹝ - - http://www.activestate.com/ - - 2. 剒減饜腔 Perl 耀郪ㄩ拸﹝ - - * Date::Parse - - 涴岆望妎暮翹奀潔蚚腔﹝ - 斕褫眕蚕 CPAN 耀郪踱狟婥假蚾 Date::Parse ㄩ - http://search.cpan.org/dist/TimeDate/ ㄛ - 麼蚚 CPAN Shell 硒俴 cpan Date::Parse 假蚾ㄛ - 麼蚚 CPANPLUS Shell 硒俴 cpanp i Date::Parse 假蚾﹝ - 蠙蒘 Debian/Ubandu Linux 妏蚚氪ㄛ褫眕硒俴 - apt-get install libtimedate-perl 假蚾﹝ - 蠙蒘 Red Hat/Fedora/CentOS Linux 妏蚚氪ㄛ褫眕硒俴 - yum install perl-TimeDate 假蚾﹝ - 蠙蒘 FreeBSD 妏蚚氪ㄛ褫眕硒俴 - ports install p5-TimeDate 假蚾﹝ - 蠙蒘 ActivePerl 妏蚚氪ㄛ褫眕硒俴 - ppm install Date::Parse 假蚾﹝ - - 蠙蒑 CPAN 麼 CPANPLUS Shell 假蚾 arclog ㄛ頗赻雄堆斕假蚾眕奻垀 - 剒腔耀郪﹝ - - 3. 恁饜腔 Perl 耀郪ㄩ - - * File::MMagic - - 涴岆潰脤紫偶濬倰蚚腔﹝藽閨訄終除 arclog 頗彸翍白 file 最 - 宒測杸﹝藾塹珩輓膛 arclog 頗蜊蚚紫帣ㄗ萵紫靡ㄘ瓚剿紫偶濬倰﹝涴 - 奀臙荓縢暱靿賱蟋童 arclog 頗拸楊瓚剿﹝ - 斕褫眕蚕 CPAN 耀郪踱狟婥假蚾 File::MMagic ㄩ - http://search.cpan.org/dist/File-MMagic/ ㄛ - 麼蚚 CPAN Shell 硒俴 cpan File::MMagic 假蚾ㄛ - 麼蚚 CPANPLUS Shell 硒俴 cpanp i File::MMagic 假蚾﹝ - 蠙蒘 Debian/Ubandu Linux 妏蚚氪ㄛ褫眕硒俴 - apt-get install libfile-mmagic-perl 假蚾﹝ - 蠙蒘 Red Hat/Fedora/CentOS Linux 妏蚚氪ㄛ褫眕硒俴 - yum install perl-File-MMagic 假蚾﹝ - 蠙蒘 FreeBSD 妏蚚氪ㄛ褫眕硒俴 - ports install p5-File-MMagic 假蚾﹝ - 蠙蒘 ActivePerl 妏蚚氪ㄛ褫眕硒俴 - ppm install File::MMagic 假蚾﹝ - 蠙蒰肴 MS-Windows 狟妏蚚 file.exe 最宒ㄛ褫眕蚕 - GnuWin32 厙桴狟婥ㄩ http://gnuwin32.sourceforge.net/ ﹝ - ③溜珫謹媞鞶炭瘚菠硨腴陬鐃溝剿瞿炸腕峈 file.exe ﹝ - - 膘祜蚚 File::MMagic ﹝ file 最宒髒嫌頗昫瓚﹝ - - * Compress::Zlib - - 涴岆揭燴 gzip 揤坫紫蚚腔ㄛ硐衄揭燴 gzip 揤坫紫奀符頗蚚善﹝ - 猁蚚奀羶衄假蚾ㄛ arclog 頗彸翍蜊蚚 gzip 最宒測杸﹝藾塹珩輓膛 - arclog 憩拸楊硒俴﹝ - 斕褫眕蚕 CPAN 耀郪踱狟婥假蚾 Compress::Zlib ㄩ - http://search.cpan.org/dist/Compress-Zlib/ ㄛ - 麼蚚 CPAN Shell 硒俴 cpan Compress::Zlib 假蚾ㄛ - 麼蚚 CPANPLUS Shell 硒俴 cpanp i Compress::Zlib 假蚾﹝ - 蠙蒘 Debian/Ubandu Linux 妏蚚氪ㄛ褫眕硒俴 - apt-get install libcompress-zlib-perl 假蚾﹝ - 蠙蒘 Red Hat/Fedora/CentOS Linux 妏蚚氪ㄛ褫眕硒俴 - yum install perl-Compress-Zlib 假蚾﹝ - 蠙蒘 FreeBSD 妏蚚氪ㄛ褫眕硒俴 - ports install p5-Compress-Zlib 假蚾﹝ - 蠙蒘 ActivePerl 妏蚚氪ㄛ褫眕硒俴 - ppm install Compress::Zlib 假蚾﹝ - 蠙蒰肴 MS-Windows 狟妏蚚 gzip.exe 最宒ㄛ褫眕蚕 - gzip 厙桴狟婥ㄩ http://www.gzip.org/ ﹝ - ③溜珫謹媞鞶炭瘚菠硨腴陬鐃溝剿瞿炸腕峈 gzip.exe ﹝ - - * Compress::Bzip2 菴媼唳眕奻 - - 涴岆盓堔黍迡 bzip2 揤坫紫蚚腔ㄛ硐衄揭燴 bzip2 揤坫紫奀符頗蚚 - 善﹝譣肩蟾掙閨訄終除 arclog 頗彸翍蜊蚚 bzip2 最宒測杸﹝藾塹 - 祥善ㄛ arclog 憩拸楊硒俴﹝ - 斕褫眕蚕 CPAN 耀郪踱狟婥假蚾 Compress::Bzip2 ㄩ - http://search.cpan.org/dist/Compress-Bzip2/ ㄛ - 麼蚚 CPAN Shell 硒俴 cpan Compress::Bzip2 假蚾ㄛ - 麼蚚 CPANPLUS Shell 硒俴 cpanp i Compress::Bzip2 假蚾﹝ - 蠙蒘 Debian/Ubandu Linux 妏蚚氪ㄛ褫眕硒俴 - apt-get install libcompress-bzip2-perl 假蚾﹝ - 蠙蒘 Red Hat/Fedora/CentOS Linux 妏蚚氪ㄛ褫眕硒俴 - yum install perl-Compress-Bzip2 假蚾﹝ - 蠙蒘 FreeBSD 妏蚚氪ㄛ褫眕硒俴 - ports install p5-Compress-Bzip2 假蚾﹝ - 蠙蒘 ActivePerl 妏蚚氪ㄛ褫眕硒俴 - ppm install Compress::Bzip2 假蚾﹝ - 蠙蒰肴 MS-Windows 狟妏蚚 bzip2.exe 最宒ㄛ褫眕蚕 - bzip2 厙桴狟婥ㄩ http://www.bzip.org/ ﹝ - ③溜珫謹媞鞶炭瘚菠硨腴陬鐃溝剿瞿炸腕峈 bzip2.exe ﹝ - - * Term::ReadKey - - 涴岆珆尨輛僅蹈蚚腔ㄛ藽閨訄終除狡芠遙慺埰噬禷蹈﹝森俋祥頗衄 - 庥恄帎漶ˊ禷蹈褫眕藥蒹 arclog 腔馱釬輛僅珨醴賸說 - 斕褫眕蚕 CPAN 耀郪踱狟婥假蚾 Term::ReadKey ㄩ - http://search.cpan.org/dist/TermReadKey/ ㄛ - 麼蚚 CPAN Shell 硒俴 cpan Term::ReadKey 假蚾ㄛ - 麼蚚 CPANPLUS Shell 硒俴 cpanp i Term::ReadKey 假蚾﹝ - 蠙蒘 Debian/Ubandu Linux 妏蚚氪ㄛ褫眕硒俴 - apt-get install libterm-readkey-perl 假蚾﹝ - 蠙蒘 Red Hat/Fedora/CentOS Linux 妏蚚氪ㄛ褫眕硒俴 - yum install perl-TermReadKey 假蚾﹝ - 蠙蒘 FreeBSD 妏蚚氪ㄛ褫眕硒俴 - ports install p5-Term-ReadKey 假蚾﹝ - 蠙蒘 ActivePerl 妏蚚氪ㄛ褫眕硒俴 - ppm install Term::ReadKey 假蚾﹝ - - -♁假蚾硌鰍 - - 蠙蒘к arclog.pl 2.1.1dev4 眕ヶ腔唳掛汔撰ㄛ③統堐 UPGRADE.zh-tw -紫腔汔撰佽隴﹝ - -♁♁眕 ExtUtils::MakeMaker 假蚾 - - arclog 蚚 Perl 梓袧腔 ExtUtils::MakeMaker 假蚾ㄛ最唗覤瞿 - - % perl Makefile.PL - % make - % make test - % make install - - 婓 make install ヶㄛ③珂溜狦蒑俶痚終凰螞撈瘚紫饑使煄籵都涴奀緊 -猁з遙峈 root ㄛ符夔假蚾湔紫﹝ - - 蠙蒘к MS-Windows 狟腔 ActivePerl ㄛ make ③蜊蚚 nmake ﹝ nmake -褫蚕峚穔 FTP 桴狟婥ㄩ - - ftp://ftp.microsoft.com/Softlib/MSLFILES/nmake15.exe - - 譣狐終做複頖華源ㄛ③扢隅疑 PREFIX ﹝瞰蝤皆趕蒘墓譏舝皆狐終啪 -赻撩腔醴翹狟奀ㄩ - - % perl Makefile.PL PREFIX=/home/jessica - - 猁眭耋載嗣假蚾恁砐腔牉誹ㄛ③統堐 ExtUtils::MakeMaker 腔佽隴ㄗ③硒 -俴 perldoc ExtUtils::MakeMaker ㄘ﹝ - - -♁♁眕 Module::Build 假蚾 - - 蠙蓔祥閎皆窒奿娸 Module::Build 假蚾ㄛ最唗覤瞿 - - % perl Build.PL - % ./Build - % ./Build test - % ./Build install - - 婓 ./Build install ヶㄛ③珂溜狦蒑俶痚終凰螞撈瘚紫饑使煄籵都涴奀 -緊猁з遙峈 root ㄛ符夔假蚾湔紫﹝ - - 譣狐終做複頖華源ㄛ③扢隅疑 --prefix ﹝瞰蝤皆趕蒘墓譏舝皆狐終 -婓赻撩腔醴翹狟奀ㄩ - - % perl Build.PL --prefix=/home/jessica - - 猁眭耋載嗣假蚾恁砐腔牉誹ㄛ③統堐 Module::Build 腔佽隴ㄗ③硒俴 -perldoc Module::Build ㄘ﹝ - - -甡鎖癡 -2008-11-18 -imacat@mail.imacat.idv.tw -http://www.imacat.idv.tw/ diff --git a/INSTALL.zh-tw b/INSTALL.zh-tw deleted file mode 100644 index cf66eea..0000000 --- a/INSTALL.zh-tw +++ /dev/null @@ -1,186 +0,0 @@ -arclog 安裝指南 - -◎目錄 - - ◎系統需求 - ◎安裝指南 - ◎◎以 ExtUtils::MakeMaker 安裝 - ◎◎以 Module::Build 安裝 - - -◎系統需求 - - 1. Perl 5.8.0 或以上。 arclog 使用三參數的 open() 以複製檔案操作, -我還不知道怎麼改寫到更早的版本上執行。若妳可以改寫到更早的版本上執行, -請告訴我。妳可以輸入 perl -v 查詢妳目前的 Perl 版本。目前大多數的 Unix -系統都有 Perl 。如果妳沒有 Perl 或需要昇級,可以到 Perl 網站下載安裝最 -新版 Perl 。 - - http://www.perl.com/ - - 若妳用 MS-Windows ,可以下載安裝 ActiveState 公司的 ActivePerl 。 - - http://www.activestate.com/ - - 2. 需搭配的 Perl 模組:無。 - - * Date::Parse - - 這是辨識記錄時間用的。 - 妳可以由 CPAN 模組庫下載安裝 Date::Parse : - http://search.cpan.org/dist/TimeDate/ , - 或用 CPAN Shell 執行 cpan Date::Parse 安裝, - 或用 CPANPLUS Shell 執行 cpanp i Date::Parse 安裝。 - 若妳是 Debian/Ubandu Linux 使用者,可以執行 - apt-get install libtimedate-perl 安裝。 - 若妳是 Red Hat/Fedora/CentOS Linux 使用者,可以執行 - yum install perl-TimeDate 安裝。 - 若妳是 FreeBSD 使用者,可以執行 - ports install p5-TimeDate 安裝。 - 若妳是 ActivePerl 使用者,可以執行 - ppm install Date::Parse 安裝。 - - 若妳由 CPAN 或 CPANPLUS Shell 安裝 arclog ,會自動幫妳安裝以上所 - 需的模組。 - - 3. 選配的 Perl 模組: - - * File::MMagic - - 這是檢查檔案類型用的。若沒有安裝, arclog 會試著去找 file 程 - 式代替。若還找不到, arclog 會改用檔尾(副檔名)判斷檔案類型。這 - 時若從標準輸入讀檔, arclog 會無法判斷。 - 妳可以由 CPAN 模組庫下載安裝 File::MMagic : - http://search.cpan.org/dist/File-MMagic/ , - 或用 CPAN Shell 執行 cpan File::MMagic 安裝, - 或用 CPANPLUS Shell 執行 cpanp i File::MMagic 安裝。 - 若妳是 Debian/Ubandu Linux 使用者,可以執行 - apt-get install libfile-mmagic-perl 安裝。 - 若妳是 Red Hat/Fedora/CentOS Linux 使用者,可以執行 - yum install perl-File-MMagic 安裝。 - 若妳是 FreeBSD 使用者,可以執行 - ports install p5-File-MMagic 安裝。 - 若妳是 ActivePerl 使用者,可以執行 - ppm install File::MMagic 安裝。 - 若妳要在 MS-Windows 下使用 file.exe 程式,可以由 - GnuWin32 網站下載: http://gnuwin32.sourceforge.net/ 。 - 請確認下載後,存檔在系統的路徑下,檔名為 file.exe 。 - - 建議用 File::MMagic 。 file 程式偶爾會誤判。 - - * Compress::Zlib - - 這是處理 gzip 壓縮檔用的,只有處理 gzip 壓縮檔時才會用到。若 - 要用時沒有安裝, arclog 會試著改用 gzip 程式代替。若還找不到, - arclog 就無法執行。 - 妳可以由 CPAN 模組庫下載安裝 Compress::Zlib : - http://search.cpan.org/dist/Compress-Zlib/ , - 或用 CPAN Shell 執行 cpan Compress::Zlib 安裝, - 或用 CPANPLUS Shell 執行 cpanp i Compress::Zlib 安裝。 - 若妳是 Debian/Ubandu Linux 使用者,可以執行 - apt-get install libcompress-zlib-perl 安裝。 - 若妳是 Red Hat/Fedora/CentOS Linux 使用者,可以執行 - yum install perl-Compress-Zlib 安裝。 - 若妳是 FreeBSD 使用者,可以執行 - ports install p5-Compress-Zlib 安裝。 - 若妳是 ActivePerl 使用者,可以執行 - ppm install Compress::Zlib 安裝。 - 若妳要在 MS-Windows 下使用 gzip.exe 程式,可以由 - gzip 網站下載: http://www.gzip.org/ 。 - 請確認下載後,存檔在系統的路徑下,檔名為 gzip.exe 。 - - * Compress::Bzip2 第二版以上 - - 這是支援讀寫 bzip2 壓縮檔用的,只有處理 bzip2 壓縮檔時才會用 - 到。若要用時沒有安裝, arclog 會試著改用 bzip2 程式代替。若還找 - 不到, arclog 就無法執行。 - 妳可以由 CPAN 模組庫下載安裝 Compress::Bzip2 : - http://search.cpan.org/dist/Compress-Bzip2/ , - 或用 CPAN Shell 執行 cpan Compress::Bzip2 安裝, - 或用 CPANPLUS Shell 執行 cpanp i Compress::Bzip2 安裝。 - 若妳是 Debian/Ubandu Linux 使用者,可以執行 - apt-get install libcompress-bzip2-perl 安裝。 - 若妳是 Red Hat/Fedora/CentOS Linux 使用者,可以執行 - yum install perl-Compress-Bzip2 安裝。 - 若妳是 FreeBSD 使用者,可以執行 - ports install p5-Compress-Bzip2 安裝。 - 若妳是 ActivePerl 使用者,可以執行 - ppm install Compress::Bzip2 安裝。 - 若妳要在 MS-Windows 下使用 bzip2.exe 程式,可以由 - bzip2 網站下載: http://www.bzip.org/ 。 - 請確認下載後,存檔在系統的路徑下,檔名為 bzip2.exe 。 - - * Term::ReadKey - - 這是顯示進度列用的,若沒有安裝,就不會顯示進度列。此外不會有 - 任何問題。進度列可以讓妳對 arclog 的工作進度一目瞭然。 - 妳可以由 CPAN 模組庫下載安裝 Term::ReadKey : - http://search.cpan.org/dist/TermReadKey/ , - 或用 CPAN Shell 執行 cpan Term::ReadKey 安裝, - 或用 CPANPLUS Shell 執行 cpanp i Term::ReadKey 安裝。 - 若妳是 Debian/Ubandu Linux 使用者,可以執行 - apt-get install libterm-readkey-perl 安裝。 - 若妳是 Red Hat/Fedora/CentOS Linux 使用者,可以執行 - yum install perl-TermReadKey 安裝。 - 若妳是 FreeBSD 使用者,可以執行 - ports install p5-Term-ReadKey 安裝。 - 若妳是 ActivePerl 使用者,可以執行 - ppm install Term::ReadKey 安裝。 - - -◎安裝指南 - - 若妳是由 arclog.pl 2.1.1dev4 以前的版本昇級,請參閱 UPGRADE.zh-tw -檔的昇級說明。 - -◎◎以 ExtUtils::MakeMaker 安裝 - - arclog 用 Perl 標準的 ExtUtils::MakeMaker 安裝,程序如下: - - % perl Makefile.PL - % make - % make test - % make install - - 在 make install 前,請先確認妳有在安裝目錄存檔的權限。通常這時候 -要切換為 root ,才能安裝存檔。 - - 若妳是用 MS-Windows 下的 ActivePerl , make 請改用 nmake 。 nmake -可由微軟的 FTP 站下載: - - ftp://ftp.microsoft.com/Softlib/MSLFILES/nmake15.exe - - 若要安裝到其它地方,請設定好 PREFIX 。例如,一般使用者,要安裝在 -自己的目錄下時: - - % perl Makefile.PL PREFIX=/home/jessica - - 要知道更多安裝選項的細節,請參閱 ExtUtils::MakeMaker 的說明(請執 -行 perldoc ExtUtils::MakeMaker )。 - - -◎◎以 Module::Build 安裝 - - 若妳喜歡,也可以用 Module::Build 安裝,程序如下: - - % perl Build.PL - % ./Build - % ./Build test - % ./Build install - - 在 ./Build install 前,請先確認妳有在安裝目錄存檔的權限。通常這時 -候要切換為 root ,才能安裝存檔。 - - 若要安裝到其它地方,請設定好 --prefix 。例如,一般使用者,要安裝 -在自己的目錄下時: - - % perl Build.PL --prefix=/home/jessica - - 要知道更多安裝選項的細節,請參閱 Module::Build 的說明(請執行 -perldoc Module::Build )。 - - -依瑪貓 -2008-11-18 -imacat@mail.imacat.idv.tw -http://www.imacat.idv.tw/ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/MANIFEST b/MANIFEST deleted file mode 100644 index 6c6f675..0000000 --- a/MANIFEST +++ /dev/null @@ -1,39 +0,0 @@ -arclog -arclog.en.html -arclog.zh-cn.html -arclog.zh-tw.html -AUTHORS -AUTHORS.zh-cn -AUTHORS.zh-tw -Build.PL -Changes -COPYING -fdl.txt -INSTALL -INSTALL.zh-cn -INSTALL.zh-tw -Makefile.PL -MANIFEST This list of files -META.yml -NEWS -pgpkey.asc -README -README.zh-cn -README.zh-tw -SIGNATURE -t/00-signature.t -t/01-exhaust.t -t/02-several.t -t/03-fallback.t -t/04-errors.t -t/99-pod.t -t/_helper.pm -THANKS -THANKS.zh-cn -THANKS.zh-tw -TODO -TODO.zh-cn -TODO.zh-tw -UPGRADE -UPGRADE.zh-cn -UPGRADE.zh-tw diff --git a/MANIFEST.SKIP b/MANIFEST.SKIP new file mode 100644 index 0000000..4b50038 --- /dev/null +++ b/MANIFEST.SKIP @@ -0,0 +1,14 @@ +^blib/ +^Makefile$ +^Build$ +^_build/ +^MANIFEST\.bak$ +^MYMETA\.yml$ +^MYMETA\.json$ +^SIGNATURE$ +^pm_to_blib$ +^\.git/ +^\.gitignore$ +^\.idea/ +^excludes/ +^t/logs.*/ diff --git a/META.yml b/META.yml deleted file mode 100644 index 671b5e1..0000000 --- a/META.yml +++ /dev/null @@ -1,14 +0,0 @@ ---- #YAML:1.0 -name: arclog -version: 3.04 -abstract: Archive log files monthly -license: gpl -author: - - imacat -generated_by: ExtUtils::MakeMaker version 6.38 -distribution_type: module -requires: - Date::Parse: 0 -meta-spec: - url: http://module-build.sourceforge.net/META-spec-v1.3.html - version: 1.3 diff --git a/Makefile.PL b/Makefile.PL index 75d7d3e..ff52ca0 100755 --- a/Makefile.PL +++ b/Makefile.PL @@ -7,7 +7,7 @@ use Config qw(%Config); use ExtUtils::MakeMaker; # Check if there is any old file -use vars qw(%old_version); +our (%old_version); %old_version = qw(); foreach (qw(/usr/sbin/arclog.pl /usr/sbin/arclog @@ -49,7 +49,7 @@ EOT } # Optional prerequisite modules -use vars qw(%OPT_PREREQ); +our (%OPT_PREREQ); %OPT_PREREQ = ( "File::MMagic" => 0, "Compress::Zlib" => 0, @@ -72,7 +72,7 @@ WriteMakefile( VERSION_FROM => "arclog", ABSTRACT => "Archive log files monthly", AUTHOR => "imacat ", - LICENSE => "gpl", + LICENSE => "apache_2_0", PREREQ_PM => { "Date::Parse" => 0, }, diff --git a/NEWS b/NEWS deleted file mode 100644 index 60556ba..0000000 --- a/NEWS +++ /dev/null @@ -1,29 +0,0 @@ -New in 3.04: -* Documentation fixes. - -New in 3.03: -* Test suite fixes. -* Required Perl version number compatible to older versions, to work - with the Perl 5.10 warning. - -New in 3.02: -* Test suite improvement. - -New in 3.01: -* Test suite improvement. - -New in 3.00: -* Name changed from arclog.pl to arclog. -* Perl's s build system ExtUtils::MakeMaker and Module::Build are - used instead of GNU autoconf. -* Added test suite that help quality assurance. -* License updated to GPLv3. - -New in 2.1.0: -* Added support for bzip2 compression. -* Added support for gzip compression with gzip binary instead of - Compress::Zlib. -* Added the GNU autoconf configuration script. - -New in 2.1.0dev2: -* Documentation fixes. diff --git a/README b/README deleted file mode 100644 index 36b87a0..0000000 --- a/README +++ /dev/null @@ -1,67 +0,0 @@ -arclog - Archive the log files monthly - - Copyright (c) 2001-2007 imacat. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - - arclog archives the log files monthly. It strips off previous months' -log records from the log file, and save them to compressed archive files -named logfile.yyyymm. It then saves the hard disk space and prevents -potential attacks on log files. - - Currently, arclog supports Apache access log, Syslog, NTP, Apache 1 SSL -engine log and my own bracketed, modified ISO date/time log file formats, and -gzip and bzip2 compression methods. Several software projects log (or can -log) in a format compatible with the Apache access log, like CUPS, ProFTPD, -Pure-FTPd... etc., and arclog can archive their Apache-like log files, too. - - -* Documentation - - Type "perldoc arclog" to read the arclog manual. - - -* Installation - - Read INSTALL for instructions on how to install arclog. - - -* News, Changes and Updates - - Refer to the Changes for changes, bug fixes, updates, new functions, etc. - - -* Support - - arclog's website is at http://arclog.sourceforge.net/. Visit the website -for the current information of arclog. - - arclog has a mailing list arclog-users@lists.sourceforge.net. If you have -any question, comment, bug report, patch, please send it to the mailing list. -Join the list at https://lists.sourceforge.net/lists/listinfo/arclog-users . -Do not send mails directly to me unless you have private business with me. -The mailing list has an archive. People having the same trouble as you may -search the archive, find the answer and save a lot of time. - - -* License - - This program is distributed under GNU Gneral Pulbic License (GPL). Please -refer to the COPYING file for the copyright and the license of this program. - - -imacat ^_*' -2007-12-03 -imacat@mail.imacat.idv.tw -http://www.imacat.idv.tw/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..4cb7fe0 --- /dev/null +++ b/README.md @@ -0,0 +1,613 @@ +`arclog` - Archive the Log Files Monthly +======================================== + + +Description +----------- + +`arclog` archives the log files monthly. It strips off previous +months log records from the log file, and save them to compressed +archive files named `logfile.yyyymm`. It then saves the hard disk +space and prevents potential attacks on log files. + +Currently, `arclog` supports [Apache] access log, Syslog, [NTP], +Apache 1 SSL engine log, and my own bracketed, modified ISO date/time +log file formats, and gzip and bzip2 compression methods. Several +software projects log (or can log) in a format compatible with the +Apache access log, like [CUPS], [ProFTPD], [Pure-FTPd] etc., and +`arclog` can archive their Apache-like log files, too. + +Caution +======= + +* *Archival takes time*. To reduce the time occupying the source log + file, `arclog` copies the content of the source log file to a + temporary working file and restart the source log file first. Then + `arclog` can take its time working on the temporary working file. + However, please note: + + 1. If you have a huge log file (several hundreds of MBs), merely + copying still takes a lot of time. You had better stop logging + first, archive the log file and restart logging, to avoid racing + condition in writing. If you archive the log file periodically, + it shall not grow too big. + + 2. If `arclog` stops in the middle of the execution, it will leave a + temporary working file. The next time `arclog` runs, it stops + when it sees that temporary working file. You have to process + that temporary working file first. That temporary working file + is merely a copy of the original log file. You can rename and + archive it like an ordinary log file to solve this. + +* Do not sort unless you have a particular reason. Sorting has the + following potential problems: + + 1. Sorting may *eat huge memory* on large log files. The amount of + the memory required depends on the number of records in each + archived month. Modern Linux and MS-Windows kill processes that + eat too much memory, but it still takes minutes, and your system + hangs for that. I do not know other operating systems. Try at + your own risk. + + 2. The time unit of all recognized log formats is *second*. Log + records happen in a same second are sorted by the log file order + (if you are archiving several log files at a time) and then the + log record order. I try to ensure that the sorted archived + records are in a correct order of the happening events, but I + cannot guarantee. You have to watch out if the order in a second + is important. + +* Be careful on the Syslog and NTP log files: Syslog and NTP does not + record the year. `arclog` uses [Date::Parse] to parse the date, + which assumes the year between this month and last next month if the + year is missing. For example, if today is 2001/6/8, it assumes the + year between 2001/6/30 back to 2000/7/1. This is fair. However, if + you do have a Syslog or NTP log file that has records older than one + year, do not use `arclog`. It will destroy your log file. + +* If read from `STDIN`, please note: + + 1. You *must* specify the output prefix if you want to read from + `STDIN`, since what it needs is an output pathname prefix, not an + output file. + + 2. `STDIN` cannot be deleted, restarted or partially kept. If you + read from `STDIN`, the keep mode is always "keep all". If you + archive several source log files including `STDIN`, the keep mode + will be "keep all" for all source log files, to prevent disaster. + + 3. The answers of the `ask` mode is obtained from `STDIN`, too. + Since you have only one `STDIN`, you cannot specify the ask mode + while reading from `STDIN`. It falls back to the fail mode in + that case. + +* I suggest that you install [File::MMagic] instead of counting on the + `file` executable. The internal magic file of File::MMagic works + better than the `file` executable. `arclog` treats everything not + gzip nor bzip2 compressed as plain text. When a compressed log file + is wrongly recognized as an image, `arclog` treats it as plain text, + reads directly from it, and fails. This does not hurt the source + log files, but is still annoying. + +[Date::Parse]: https://metacpan.org/release/TimeDate +[File::MMagic]: https://metacpan.org/release/File-MMagic + + +System Requirement +------------------ + +1. Perl, version 5.8.0 or above. `arclog` uses 3-argument open() to + duplicate file handles, which is only supported since 5.8.0. I + have not successfully port this onto earlier versions yet. Please + tell me if you made it. You can run `perl -v` to see your current + Perl version. If you do not have Perl, or if you have an older + version of Perl, you can download and install/upgrade it from the + [Perl website]. If you are using MS-Windows, you can download and + install [ActiveState ActivePerl]. + +2. Required Perl modules: + + * [Date::Parse] + + This is used to parse the timestamp of the log records. You can + download and install Date::Parse from the CPAN archive, or + install it with the CPAN shell: + + cpan Date::Parse + + or with the CPANPLUS shell: + + cpanp i Date::Parse + + For Debian/Ubuntu: + + sudo apt install libtimedate-perl + + For Red Hat/Fedora/CentOS: + + sudo yum install perl-TimeDate + + For FreeBSD: + + ports install p5-TimeDate + + For ActivePerl: + + ppm install TimeDate + +3. Optional Perl modules: + + * [File::MMagic] + + This is used to check the file type. If this is not available, + `arclog` tries the `file` executable instead. If that is not + available, too, `arclog` judges the file type by its name suffix + (extension). In that case `arclog` fails when reading from + `STDIN`. You can download and install File::MMagic from the CPAN + archive, or install it with the CPAN shell: + + cpan File::MMagic + + or with the CPANPLUS shell: + + cpanp i File::MMagic + + For Debian/Ubuntu: + + sudo apt install libfile-mmagic-perl + + For Red Hat/Fedora/CentOS: + + sudo yum install perl-File-MMagic + + For FreeBSD: + + ports install p5-File-MMagic + + For ActivePerl: + + ppm install File-MMagic + + The alternative `file.exe` for MS-Windows can be obtained from + the [GnuWin32] home page. Be sure to save it as `file.exe` + somewhere in your `PATH`. + + * [Compress::Zlib] + + This is used to support reading/writing the gzip compressed + files. It is only needed when gzip compressed files are + encountered. If it is not available, `arclog` tries the `gzip` + executable instead. If that is not available, too, `arclog` + fails. You can download and install Compress::Zlib from the CPAN + archive, or install it with the CPAN shell: + + cpan Compress::Zlib + + or with the CPANPLUS shell: + + cpanp i Compress::Zlib + + For Debian/Ubuntu: + + sudo apt install libcompress-zlib-perl + + For Red Hat/Fedora/CentOS: + + sudo yum install perl-Compress-Zlib + + For FreeBSD: + + ports install p5-Compress-Zlib + + For ActivePerl: + + ppm install Compress-Zlib + + The alternative `gzip.exe` for MS-Windows can be obtained from + [the gzip website]. Be sure to save it as `gzip.exe` somewhere + in your `PATH`. + + * [Compress::Bzip2] version 2 or above. + + This is used to support reading/writing the bzip2 compressed + files. It is only needed when bzip2 compressed files are + encountered. If it is not available, `arclog` tries the `bzip2` + executable instead. If that is not available, too, `arclog` + fails. Notice that older versions before 2 does not work, since + the file I/O compression was not implemented yet. You can + download and install Compress::Bzip2 from the CPAN archive, or + install it with the CPAN shell: + + cpan Compress::Bzip2 + + or with the CPANPLUS shell: + + cpanp i Compress::Bzip2 + + For Debian/Ubuntu: + + sudo apt install libcompress-bzip2-perl + + For Red Hat/Fedora/CentOS: + + sudo yum install perl-Compress-Bzip2 + + For FreeBSD: + + ports install p5-Compress-Bzip2 + + For ActivePerl: + + ppm install Compress-Bzip2 + + The alternative `bzip2.exe` for MS-Windows can be obtained from + [the bzip2 website]. Be sure to save it as `bzip2.exe` somewhere + in your `PATH`. + + * [Term::ReadKey] + + This is used to display the progress bar. The progress bar is a + good visual feedback of what `arclog` is currently doing, but + `arclog` is safe without it. You can download and install + Term::ReadKey from the CPAN archive, or install it with the + CPAN shell: + + cpan Term::ReadKey + + or with the CPANPLUS shell: + + cpanp i Term::ReadKey + + For Debian/Ubuntu: + + sudo apt install libterm-readkey-perl + + For Red Hat/Fedora/CentOS: + + sudo yum install perl-TermReadKey + + For FreeBSD: + + ports install p5-Term-ReadKey + + For ActivePerl: + + ppm install TermReadKey + +[Perl website]: https://www.perl.org +[ActiveState ActivePerl]: https://www.activestate.com +[Date::Parse]: https://metacpan.org/release/TimeDate +[File::MMagic]: https://metacpan.org/release/File-MMagic +[GnuWin32]: http://gnuwin32.sourceforge.net +[Compress::Zlib]: https://metacpan.org/release/Compress-Zlib +[the gzip website]: https://www.gzip.org +[Compress::Bzip2]: https://metacpan.org/release/Compress-Bzip2 +[the bzip2 website]: http://www.bzip.org +[Term::ReadKey]: https://metacpan.org/release/TermReadKey + + +Download +-------- + +`arclog` is hosted is on + +* [arclog project on GitHub] + +* [arclog project on SourceForge] + +You can always download the newest version of `arclog` from + +* [arclog download on SourceForge] + +* [Tavern IMACATs FTP directory] + +imacats PGP public key is at + +* [imacats PGP key at Tavern IMACATs] + +[arclog project on GitHub]: https://github.com/imacat/arclog +[arclog project on SourceForge]: https://sf.net/p/arclog +[arclog download on SourceForge]: https://sourceforge.net/projects/arclog/files +[Tavern IMACATs FTP directory]: https://ftp.imacat.idv.tw/pub/arclog/ +[imacats PGP key at Tavern IMACATs]: https://www.imacat.idv.tw/me/pgpkey.asc + + +Install +------- + +If you are upgrading from `arclog.pl` 2.1.1dev4 or earlier, please +read the upgrade instruction later in this document. + +### Install with [ExtUtils::MakeMaker] + +`arclog` uses standard Perl installation with ExtUtils::MakeMaker. +Follow these steps: + + % perl Makefile.PL + % make + % make test + % make install + +When running `make install`, make sure you have the privilege to +write to the installation location. This usually requires the `root` +privilege. + +If you are using ActivePerl under MS-Windows, you should use `nmake` +instead of `make`. [nmake can be obtained from the Microsoft FTP site.] + +If you want to install into another location, you can set the +`PREFIX`. For example, to install into your home when you are not +`root`: + + % perl Makefile.PL PREFIX=/home/jessica + +Refer to the documentation of ExtUtils::MakeMaker for more +installation options (by running `perldoc ExtUtils::MakeMaker`). + +### Install with [Module::Build] + +You can install with Module::Build instead, if you prefer. Follow +these steps: + + % perl Build.PL + % ./Build + % ./Build test + % ./Build install + +When running `./Build install`, make sure you have the privilege to +write to the installation location. This usually requires the `root` +privilege. + +If you want to install into another location, you can set the +`--prefix`. For example, to install into your home when you are not +`root`: + + % perl Build.PL --prefix=/home/jessica + +Refer to the documentation of Module::Build for more installation +options (by running `perldoc Module::Build`). + +[ExtUtils::MakeMaker]: https://metacpan.org/release/ExtUtils-MakeMaker +[nmake can be obtained from the Microsoft FTP site.]: ftp://ftp.microsoft.com/Softlib/MSLFILES/nmake15.exe +[Module::Build]: https://metacpan.org/release/Module-Build + + +Upgrade Instruction +------------------- + +Here are a few hints for people upgrading from 2.1.1dev4 or earlier: + +### The Script Name is Changed from `arclog.pl` to `arclog` + +This is obvious. If you have any scripts or cron jobs that are +running `arclog`, remember to modify your script for the new name. +Of course, you can rename `arclog` to `arclog.pl`. It still works. + +The reason I changed the script and project name is that: A dot `.` +in the project name is not valid everywhere. At least SourceForge +dont accept it. Besides, `arclog` is enough for a script name under +UNIX. The `.pl` file name suffix/extension may be convenient on +MS-Windows, but MS-Windows users wont run it with explorer file name +association anyway, and there is a `pl2bat` to convert `arclog` to +`arclog.bat`, which would make more sense. The only disadvantage is +that I was using `UltraEdit`, which depends on the file name extension +for the syntax highlighting rules. I can manually set it anyway. Im +using `gedit` on Linux now. This is not a problem anymore. + + +### The Default Installation Location Is at `/usr/bin` + +Also, the man page is at `/usr/share/man/man1/arclog.1`. This is to +follow Perls standard convention, and to avoid breaking +ExtUtils::MakeMaker with future versions. + +When you run `perl Makefile.PL` or `perl Build.PL`, it hints a +list of existing old files to be removed. Please delete them +manually. + +If you saved them in other places, you have to delete them yourself. + +Also, if you have any scripts or cron jobs that are running `arclog`, +remember to modify your script for the new `arclog` location. Of +course, you can copy `arclog` to the original location. It still +works. + + +### The Argument of `--keep` and `--override` Options Are Required Now + +Support for omitting the `--keep` or `--override` arguments are +removed. This helps to avoid confusion for the log file name and the +option arguments. + + +Options +------- + + ./arclog [options] logfile [output] + ./arclog [-h|-v] + +* `logfile` + + The log file to be archived. Specify `-` to read from `STDIN`. + You can specify multiple log files. `gzip` or `bzip2` compressed + files are supported. + +* `output` + + The prefix of the output files. The output files are named as + `output.yyyymm`, i.e., `output.200101`, `output.200102`. If not + specified, the default is the same as the log file. You must + specify this if you want to read from `STDIN`. You cannot specify + `-` (`STDOUT`), since `arclog` needs a name prefix, not the output + file. + +* `-c`, `--compress method` + + Specify the compression method for the archived files. Log files + usually have large number of similar lines. Compress them saves you + lots of disk spaces. (And this is why we want to archive them.) + The following compression methods are supported: + + * `g`, `gzip` + + Compress with `gzip`. This is the default. `arclog` can use + `Compress::Zlib` to compress instead of calling `gzip`. This can + be safer and faster for not calling foreign binaries. If + `Compress::Zlib` is not installed, it tries `gzip` instead. If + `gzip` is not available, either, it fails. + + * `b`, `bzip2` + + Compress with `bzip2`. `arclog` can use `Compress::Bzip2` to + compress instead of calling `bzip2`. This can be safer and faster + for not calling foreign binaries. If `Compress::Bzip2` is not + installed, it tries `bzip2` instead. If `bzip2` is not available, + either, it fails. + + * `n`, `none` + + No compression at all. (Why? :p) + +* `--nocompress` + + Do not compress the archived files. This is equivalent to + `--compress none`. + +* `-s`, `--sort` + + Sort the records by time (and then the record order). Sorting eats + huge memory and CPU, so it is disabled by default. Refer to the + description above for a detailed illustration on sorting. + +* `--nosort` + + Do not sort the records. This is the default. + +* `-o`, `--override mode` + + What to do with the existing archived files. The following modes + are supported: + + * `o`, `overwrite` + + Overwrite existing target files. You will lose these existing + records. Use with care. This is helpful if you are sure the + main log file has the most complete records. + + * `a`, `append` + + Append the records to the existing target files. You may destroy + the log file completely by putting irrelevant entries altogether + by accident. Use with care. This is helpful if you append want + to merge 2 or more log files, for example, 2 log files of + different periods. + + * `i`, `ignore` + + Ignore any existing target file, and discard all the records of + those months. You will lose these log records. Use with care. + This is helpful if you are supplying log records for the missing + months, or if you are merging the log records in a complex manner. + + * `f`, `fail` + + Stop whenever a target file exists, to prevent destroying existing + files by accident. This should be mostly desired when run from + some automatic mechanism, like `crontab`. So, this is the default + if no terminal is found at `STDIN`. + + * `ask` + + Ask you what to do when a target file exists. This should be + mostly desired if you are running `arclog` interactively. So, + this is the default if a terminal is found at `STDIN`. The + answers are read from `STDIN`. Since you have only one `STDIN`, + you cannot specify this mode if you want read the log file from + `STDIN`. In that case, it falls back to the `fail` mode. Also, + if `arclog` cannot get its answer from `STDIN`, for example, on a + closed `STDIN` from `crontab`, it falls back to `fail` mode. + +* `-k`, `--keep mode` + + What to keep in the source file. Currently, the following modes are + supported: + + * `a`, `all` + + Keep the source file after records are archived. + + * `r`, `restart` + + Restart the source log file after records are archived. + + * `d`, `delete` + + Delete the source log file after records are archived. + + * `t`, `this-month` + + Archive and strip records of previous months off from the log + file. Keep the records of this month in the source log file, to + be archived next month. This is designed to be run from `crontab` + monthly, so this is the default. + +* `-d`, `--debug` + + Show the detailed debugging messages. More `-d` to be more + detailed. + +* `-q`, `--quiet` + + Hush! Only yell on error. + +* `-h`, `--help` + + Display the help message and exit. + +* `-v`, `--version` + + Output version information and exit. + + +Documentation +------------- + +Type `perldoc arclog` to read the `arclog` manual. + + +News, Changes and Updates +------------------------- + +Refer to the `Changes` for changes, bug fixes, updates, new functions, +etc. + + +Support +------- + +The `arclog` project is hosted on GitHub. Address your issues on the +GitHub issue tracker https://github.com/imacat/arclog/issues. + + +License +------- + + Copyright (C) 2001-2021 imacat. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + +imacat ^_*' +2007/12/3 + +https://www.imacat.idv.tw diff --git a/README.zh-cn b/README.zh-cn deleted file mode 100644 index d58008d..0000000 --- a/README.zh-cn +++ /dev/null @@ -1,58 +0,0 @@ -arclog - 暮翹紫藩堎寥紫最宒 - - 唳佯齾 (c) 2001-2007 甡鎖癡 - - 掛最宒岆赻蚕篱憯珀褫眕郩桽赻蚕篱撱虌蟧 (Free Software Foundation) - 堤唳腔 GNU 籵蚚鼠僕勍褫痐沭遴 (GNU General Public License) 菴唳懂党 - 蜊睿笭陔楷票涴珨最宒ㄛ麼氪赻蚕恁寁妏蚚庥庛陔腔唳掛﹝ - - 楷票涴珨最宒腔醴腔岆洷咡坳衄蚚ㄛ筍羶衄庥庰ㄠㄐ朼祫羶衄巠磁杻隅醴腔 - 奧笐漪腔童悵﹝載砆牉腔①錶③統堐 GNU 籵蚚鼠僕勍褫痐﹝ - - 蠟茼蜆眒冪睿最宒珨れ彶善珨爺 GNU 籵蚚鼠僕勍褫痐腔萵掛﹝蝜遜羶衄ㄛ統 - 堐﹝ - - arclog 岆藩堎寥紫最宒ㄛ蔚暮翹紫笢ㄛヶ堎腔暮翹偌堎爺揤坫寥紫ㄛ眕誹吽茞詠諾 -潔ㄛ甜旌轎暮翹紫掩衄陑侕褪し窗 - -﹛﹛arclog 醴ヶ盓堔 Apache ﹜ Syslog ﹜ NTP ﹜ Apache 1 SSL engine log 摯扂赻 -撩蚚腔嬤說 ISO 党淏跡宒拻笱跡宒腔暮翹紫ㄛ迵 gzip 睿 bzip2 謗笱揤坫楊﹝竭嗣最 -宒飲褫眕蚚 Apache 眈敯Ъ撐絡鯓蝦Ъ慫畏 CUPS ﹜ ProFTPD ﹜ Pure-FTPd#脹ㄛ -arclog 珩褫眕寥紫涴虳 Apache 眈搛鯓蔥躁Ъ撐窗 - -♁佽隴恅璃 - -﹛﹛③怀 perldoc arclog ㄛ堐黍 arclog 腔佽隴﹝ - - -♁假蚾硌鰍 - -﹛﹛③砆堐 INSTALL.zh-tw 紫偶腔假蚾硌鰍﹝ - - -♁載陔﹜党淏佽隴 - -﹛﹛③砆堐 Changes 紫偶腔載陔佽隴ㄛ眕賸賤陔崝髡夔﹜恀枙党淏﹜載陔脹﹝ - - -♁撮扲盓堔 - -﹛﹛arclog 腔厙桴婓 http://arclog.sourceforge.net/ ㄛ③呴奀奻厙賸賤郔陔捅洘﹝ - -﹛﹛arclog 衄珨跺蚘璃籵捅 arclog-users@lists.sourceforge.net ㄛ譥倞庥恄帎漶 -膘祜﹜恀枙隙惆﹜党硃最宒ㄛ③敵善蚘璃籵捅奻﹝③蟀奻 -https://lists.sourceforge.net/lists/listinfo/arclog-users 樓輷疰З鼯宎籵捅 -﹝壺準岆佌侕蟲韗炤鵋藱貒閡肯掃衄棣顫靆牷蚘璃籵捅頗赻雄寥紫ㄛ梣鯫蠑頖剆 -眈肮恀枙ㄛ褫眕眻諉婓籵捅導紫笢梑善湘偶ㄛ誹吽湮模惘幛腔奀潔﹝ - - -♁唳享驨 - -﹛﹛掛最宒甡 GNU 籵蚚鼠僕勍褫痐 (GPL) 唳邢3慫甭貒怷 COPYING 紫偶腔佽隴ㄛ -賸賤掛最宒腔唳京硜乖硜搳 - - -甡鎖癡 imacat ^_*' -2007-12-03 -imacat@mail.imacat.idv.tw -http://www.imacat.idv.tw/ diff --git a/README.zh-tw b/README.zh-tw deleted file mode 100644 index e2c523a..0000000 --- a/README.zh-tw +++ /dev/null @@ -1,58 +0,0 @@ -arclog - 記錄檔每月歸檔程式 - - 版權所有 (c) 2001-2007 依瑪貓 - - 本程式是自由軟體,您可以遵照自由軟體基金會 (Free Software Foundation) - 出版的 GNU 通用公共許可證條款 (GNU General Public License) 第三版來修 - 改和重新發佈這一程式,或者自由選擇使用任何更新的版本。 - - 發佈這一程式的目的是希望它有用,但沒有任何擔保。甚至沒有適合特定目的 - 而隱含的擔保。更詳細的情況請參閱 GNU 通用公共許可證。 - - 您應該已經和程式一起收到一份 GNU 通用公共許可證的副本。如果還沒有,參 - 閱。 - - arclog 是每月歸檔程式,將記錄檔中,前月的記錄按月份壓縮歸檔,以節省硬碟空 -間,並避免記錄檔被有心人士破壞。 - -  arclog 目前支援 Apache 、 Syslog 、 NTP 、 Apache 1 SSL engine log 及我自 -己用的括弧 ISO 修正格式五種格式的記錄檔,與 gzip 和 bzip2 兩種壓縮法。很多程 -式都可以用 Apache 相容記錄檔格式記錄,如 CUPS 、 ProFTPD 、 Pure-FTPd…等, -arclog 也可以歸檔這些 Apache 相容格式的記錄檔。 - -◎說明文件 - -  請輸入 perldoc arclog ,閱讀 arclog 的說明。 - - -◎安裝指南 - -  請詳閱 INSTALL.zh-tw 檔案的安裝指南。 - - -◎更新、修正說明 - -  請詳閱 Changes 檔案的更新說明,以瞭解新增功能、問題修正、更新等。 - - -◎技術支援 - -  arclog 的網站在 http://arclog.sourceforge.net/ ,請隨時上網瞭解最新訊息。 - -  arclog 有一個郵件通訊 arclog-users@lists.sourceforge.net ,若有任何問題、 -建議、問題回報、修補程式,請寄到郵件通訊上。請連上 -https://lists.sourceforge.net/lists/listinfo/arclog-users 加入我們的郵件通訊 -。除非是私人事務,否則請不要直接寫信給我。郵件通訊會自動歸檔,日後若其他人有 -相同問題,可以直接在通訊舊檔中找到答案,節省大家寶貴的時間。 - - -◎版權聲明 - -  本程式依 GNU 通用公共許可證 (GPL) 版權發佈,請參考 COPYING 檔案的說明, -瞭解本程式的版權授權內容。 - - -依瑪貓 imacat ^_*' -2007-12-03 -imacat@mail.imacat.idv.tw -http://www.imacat.idv.tw/ diff --git a/SIGNATURE b/SIGNATURE deleted file mode 100644 index 98ed260..0000000 --- a/SIGNATURE +++ /dev/null @@ -1,61 +0,0 @@ -This file contains message digests of all files listed in MANIFEST, -signed via the Module::Signature module, version 0.55. - -To verify the content in this distribution, first make sure you have -Module::Signature installed, then type: - - % cpansign -v - -It will check each file's integrity, as well as the signature's -validity. If "==> Signature verified OK! <==" is not displayed, -the distribution may already have been compromised, and you should -not run its Makefile.PL or Build.PL. - ------BEGIN PGP SIGNED MESSAGE----- -Hash: SHA1 - -SHA1 91ced1a733e7448edc19eab22482508d58d7b284 AUTHORS -SHA1 c4c98cc9e7ac5e119752587d0322280a7a71d205 AUTHORS.zh-cn -SHA1 eb60ee204fcf7244fc0774ac34d05a35a281e82b AUTHORS.zh-tw -SHA1 412193f4d2ed686ed0041b3c8835461e9d440d68 Build.PL -SHA1 8624bcdae55baeef00cd11d5dfcfa60f68710a02 COPYING -SHA1 36d19de5f62f40b91d486cad7698586b56e11968 Changes -SHA1 22d80da796c88630915181541744461cf96e7f1a INSTALL -SHA1 00a2c93770fcb552b327cbc4438dc990d6d9c43d INSTALL.zh-cn -SHA1 b042e58841bcadd56bfb6dbdd52452bcd4215626 INSTALL.zh-tw -SHA1 e71173ba2be13190d51294a2b132940766c65bfd MANIFEST -SHA1 92bc0b6b053289e807fe9b339a5817cb8d7369b1 META.yml -SHA1 60c8024233f1b70534758aea970fe1a7d82bfff8 Makefile.PL -SHA1 f18322a97f991168d6a85104a8ce658f959431a1 NEWS -SHA1 183e9814e38c0fdaebc1624be8f1a32fb6649562 README -SHA1 38db34e5c056d10691f755e524b34e66bca0a981 README.zh-cn -SHA1 a01809cac1f61ced88f47d823b45c381706fe582 README.zh-tw -SHA1 3b55f1f8407b87ab8627e3a12c50836ad6429f5c THANKS -SHA1 aeb1c5d44e73163c50f0997203e49a8a029064d6 THANKS.zh-cn -SHA1 19bff4abc6eca9c61c875e8aef50fd3d44ec8034 THANKS.zh-tw -SHA1 48f5fff8ffb487089aa9fdcb9279ba3fd1c508c0 TODO -SHA1 00e67ef5268c66e8648c5f14da8e7912e2c2f9c5 TODO.zh-cn -SHA1 2e45a15082ae9630230235d7538dec63c6df18c8 TODO.zh-tw -SHA1 1f0c3a74a765a905339dd24ac344cc0ad48933e5 UPGRADE -SHA1 ef05ca4632730a76dbaf9119b3da95b7477aa6c3 UPGRADE.zh-cn -SHA1 182c625b0f13c8dcc4641adff1499bd705d9a53a UPGRADE.zh-tw -SHA1 0e45847a9428d8ec1154803e55641d1045f89f4b arclog -SHA1 dd80c79b178517f082ae9503889c36d0cb4e6cc8 arclog.en.html -SHA1 9604c39bf6d69cf3fd8bcb036f547761edf04961 arclog.zh-cn.html -SHA1 ab9d8bd14a36d68790c71044de1d7a67a34b41c5 arclog.zh-tw.html -SHA1 bd75d59f9d7d9731bfabdc48ecd19e704d218e38 fdl.txt -SHA1 520fdcf4374af210380db9e0fdaea44c904a15fc pgpkey.asc -SHA1 525f414c7a0aadc61240a4b0959ca2cda7514c75 t/00-signature.t -SHA1 96374acc016c20bdbe31dc4ce8eac89f59b642e6 t/01-exhaust.t -SHA1 504ee1023c7db80427dc633e1611521984909e9d t/02-several.t -SHA1 497de13a15b6721c5cf5c0be9551dc25a841312c t/03-fallback.t -SHA1 212ae878ffdf68742339b452ab631b0cbb340880 t/04-errors.t -SHA1 b85626024d610808bd0909989dcfb9fb20a40485 t/99-pod.t -SHA1 e698db4a84dbe5200cf37ad73667a595a23d9d04 t/_helper.pm ------BEGIN PGP SIGNATURE----- -Version: GnuPG v1.4.7 (GNU/Linux) - -iD8DBQFHVgHci9gubzC5S1wRAgU7AJwK/IesoIYHuMd2vOeyEqYrf25ViwCcD0cc -tgiH/AXhrVXGRy97R25j7H4= -=Jrgq ------END PGP SIGNATURE----- diff --git a/THANKS.zh-cn b/THANKS.zh-cn deleted file mode 100644 index f9b89d3..0000000 --- a/THANKS.zh-cn +++ /dev/null @@ -1 +0,0 @@ -﹛﹛覜郅 SourceForge 枑鼎殤扢 arclog ﹝ diff --git a/THANKS.zh-tw b/THANKS.zh-tw deleted file mode 100644 index ee0083d..0000000 --- a/THANKS.zh-tw +++ /dev/null @@ -1 +0,0 @@ -  感謝 SourceForge 提供架設 arclog 。 diff --git a/TODO b/TODO deleted file mode 100644 index a132d2b..0000000 --- a/TODO +++ /dev/null @@ -1,2 +0,0 @@ - 1. Multi-lingual support, with Traditional and Simplified Chinese - messages. diff --git a/TODO.zh-cn b/TODO.zh-cn deleted file mode 100644 index a7592fa..0000000 --- a/TODO.zh-cn +++ /dev/null @@ -1 +0,0 @@ - 1. 嗣逄趙ㄛ樓奻淏潠笢恅捅洘﹝ diff --git a/TODO.zh-tw b/TODO.zh-tw deleted file mode 100644 index fcf3af6..0000000 --- a/TODO.zh-tw +++ /dev/null @@ -1 +0,0 @@ - 1. 多語化,加上正簡中文訊息。 diff --git a/UPGRADE b/UPGRADE deleted file mode 100644 index e554874..0000000 --- a/UPGRADE +++ /dev/null @@ -1,47 +0,0 @@ -Upgrade Instruction - - Here are a few hints for people upgrading from 2.1.1dev4 or earlier: - -* The Script Name is Changed from arclog.pl to arclog - - This is obvious. If you have any scripts or cron jobs that are running -arclog, remember to modify your script for the new name. Of course, you can -rename arclog to arclog.pl. It will still work. - - The reason I changed the script and project name is that: A dot "." in -the project name is not valid everywhere. At least SourceForge don't accept -it. Besides, "arclog" is enough for a script name under UNIX. The ".pl" file -name suffix/extension may be convienent for MS-Windows, but MS-Windows users -won't run it with explorer file name association anyway, and there is a pl2bat -to convert "arclog" to "arclog.bat", which would make more sense. The only -disadvantage is that I use UltraEdit, which depends on the file name extension -for the automatic syntax highlighting rules. But this is not much trouble. I -can manuall set it anyway. - - -* The Default Installation Location Is at /usr/bin - - Also, the man page is at /usr/share/man/man1/arclog.1. This is to follow -Perl's standard convension, and to avoid breaking ExtUtils::MakeMaker with -future versions. - - When you run "perl Makefile.PL" or "perl Build.PL", it will hint a list of -old files found to be removed. Please delete them manually. - - If you saved them in other places, you have to delete them yourself. - - Also, if you have any scripts or cron jobs that are running arclog, remember -to modify your script for the new arclog location. Of course, you can copy -arclog to the original location. It will still work. - - -* The Argument of --keep and --override Options Are Required Now - - Support for omitting --keep or --override argument is removed. This helps -avoiding confusion for the log file name and the option arguments. - - -imacat -2007-11-26 -imacat@mail.imacat.idv.tw -http://www.imacat.idv.tw/ diff --git a/UPGRADE.zh-cn b/UPGRADE.zh-cn deleted file mode 100644 index 35acd20..0000000 --- a/UPGRADE.zh-cn +++ /dev/null @@ -1,39 +0,0 @@ -汔撰硌鰍 - -﹛﹛蠙蒑 2.1.1dev4 麼眳ヶ腔唳掛汔撰ㄛ③堐黍眕狟佽隴ㄩ - -♁紫靡蚕 arclog.pl 蜊峈 arclog - -﹛﹛涴竭隴珆勘﹝ :p 蠙蒑俴斑昃膛牴藙頞 cron 齬最懂硒俴 arclog ㄛ③暮腕載蜊紫 -靡﹝祥徹斕珩褫眕參 arclog 蜊靡隙埻懂腔 arclog.pl ㄛ祥頗衄庥恄帎漶 - -﹛﹛蜊靡埻秪覤瞿禍辰蜆備漪☆.★頗揭揭癲族﹝ SourceForget 憩祥諉忳漪☆.★腔蚳 -偶靡備﹝森俋ㄛ最宒靡備 arclog 婓 UNIX 狟憩褫眕變賸﹝萵紫靡 .pl 呥閩 -MS-Windows 狟源晞ㄛ筍毀淏 MS-Windows 狟珩祥頗眻諉萸謗狟甡萵紫靡硒俴﹝奧й遜衄 -pl2bat 褫眕參 arclog 蛌傖 arclog.bat ㄛ涴欴毀奧掀誕磁燴﹝峔珨祥晞腔岆扂蚚腔晤 -憮ん UltraEdit 甡萵紫靡樵隅最宒逄晟逄楊梓尨ㄛ祥徹涴珩羶妦繫湮祥賸ㄛ忒雄扢最宒 -逄晟憩疑賸﹝ - - -♁啎扢假蚾醴翹峈 /usr/bin - -﹛﹛佽隴紫寀婓 /usr/share/man/man1/arclog.1 ﹝涴岆峈睫磁 Perl 腔梓袧假蚾霜最ㄛ -敔轎ぢ輓 ExtUtils::MakeMaker 腔啎扢扢隅ㄛ婖傖梣鯠撰腔恀枙﹝ - -﹛﹛硒俴 perl Makefile.PL 麼 perl Build.PL 奀ㄛ頗枑尨斕垀婓炵苀奻楷珋腔腔導紫 -偶﹝③赻俴刉壺﹝蠙蒬昃蓬窴硤頖華源ㄛ③暮腕猁赻撩刉裁﹝ - -﹛﹛蠙蒑俴斑昃膛牴藙頞 cron 齬最懂硒俴 arclog ㄛ③暮腕載蜊紫靡﹝祥徹斕珩褫眕 -參 arclog 湔善埻懂腔醴翹奴炬遙慪倞庥恄帎漶 - - -♁ --keep 睿 --override 恁砐珋婓珨隅猁樓耀宒統杅 - -﹛﹛眕ヶ褫眕眻諉蚚 --keep 睿 --override 恁砐ㄛ祥樓統杅ㄛ珋婓珨隅猁樓統杅ㄛ眕旌 -轎髦秎恁砐腔統杅睿猁揭燴腔暮翹紫靡﹝ - - -甡鎖癡 -2007-11-26 -imacat@mail.imacat.idv.tw -http://www.imacat.idv.tw/ diff --git a/UPGRADE.zh-tw b/UPGRADE.zh-tw deleted file mode 100644 index e2bc295..0000000 --- a/UPGRADE.zh-tw +++ /dev/null @@ -1,39 +0,0 @@ -昇級指南 - -  若妳由 2.1.1dev4 或之前的版本昇級,請閱讀以下說明: - -◎檔名由 arclog.pl 改為 arclog - -  這很明顯吧。 :p 若妳有寫程式,或設定 cron 排程來執行 arclog ,請記得更改檔 -名。不過妳也可以把 arclog 改名回原來的 arclog.pl ,不會有任何問題。 - -  改名原因如下:專案名稱含「.」會處處碰壁。 SourceForget 就不接受含「.」的專 -案名稱。此外,程式名稱 arclog 在 UNIX 下就可以跑了。副檔名 .pl 雖然在 -MS-Windows 下方便,但反正 MS-Windows 下也不會直接點兩下依副檔名執行。而且還有 -pl2bat 可以把 arclog 轉成 arclog.bat ,這樣反而比較合理。唯一不便的是我用的編 -輯器 UltraEdit 依副檔名決定程式語言語法標示,不過這也沒什麼大不了,手動設程式 -語言就好了。 - - -◎預設安裝目錄為 /usr/bin - -  說明檔則在 /usr/share/man/man1/arclog.1 。這是為符合 Perl 的標準安裝流程, -敝免破壞 ExtUtils::MakeMaker 的預設設定,造成日後昇級的問題。 - -  執行 perl Makefile.PL 或 perl Build.PL 時,會提示妳所在系統上發現的的舊檔 -案。請自行刪除。若妳程式存在其它地方,請記得要自己刪掉。 - -  若妳有寫程式,或設定 cron 排程來執行 arclog ,請記得更改檔名。不過妳也可以 -把 arclog 存到原來的目錄去,不會有任何問題。 - - -◎ --keep 和 --override 選項現在一定要加模式參數 - -  以前可以直接用 --keep 和 --override 選項,不加參數,現在一定要加參數,以避 -免混淆選項的參數和要處理的記錄檔名。 - - -依瑪貓 -2007-11-26 -imacat@mail.imacat.idv.tw -http://www.imacat.idv.tw/ diff --git a/arclog b/arclog index e817114..05511b6 100755 --- a/arclog +++ b/arclog @@ -1,22 +1,21 @@ #! /usr/bin/perl -w # arclog: Archive the log files monthly -# Copyright (c) 2001-2007 imacat -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . +# Copyright (c) 2001-2021 imacat. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. -# First written: 2001-01-05 +# First written: 2001/1/5 package main; use 5.008; @@ -34,32 +33,32 @@ use File::Spec::Functions qw(devnull file_name_is_absolute path catfile use File::Temp qw(tempfile); use Config qw(); use base qw(Exporter); -use vars qw(@EXPORT @EXPORT_OK); +our (@EXPORT, @EXPORT_OK); BEGIN { -@EXPORT = qw(); -push @EXPORT, qw(COMPRESS_GZIP COMPRESS_BZIP2 COMPRESS_NONE); -push @EXPORT, qw(OVERRIDE_OVERWRITE OVERRIDE_APPEND OVERRIDE_IGNORE OVERRIDE_FAIL OVERRIDE_ASK); -push @EXPORT, qw(KEEP_ALL KEEP_RESTART KEEP_DELETE KEEP_THISMONTH); -push @EXPORT, qw(TYPE_PLAIN TYPE_GZIP TYPE_BZIP2); -push @EXPORT, qw(TMP_SUFFIX whereis to_yyyymm format_number rel2abs); +@EXPORT = qw( +COMPRESS_GZIP COMPRESS_BZIP2 COMPRESS_NONE +OVERRIDE_OVERWRITE OVERRIDE_APPEND OVERRIDE_IGNORE OVERRIDE_FAIL OVERRIDE_ASK +KEEP_ALL KEEP_RESTART KEEP_DELETE KEEP_THIS_MONTH +TYPE_PLAIN TYPE_GZIP TYPE_BZIP2 +TMP_SUFFIX where_is to_yyyymm format_number rel2abs); @EXPORT_OK = @EXPORT; # Prototype declaration sub main(); sub parse_args(); -sub whereis($); +sub where_is($); sub to_yyyymm($); sub format_number($); sub rel2abs($;$); } our ($THIS_FILE, $VERBOSE); -use vars qw($VERSION); +our ($VERSION); $THIS_FILE = basename($0); $VERSION = "3.04"; $VERBOSE = 1; -our (%CONF, @LOGFILES, $THIS_MONTH, $PROGBAR); -use vars qw(%WHEREIS); +our (%CONF, @LOGFILES, $THIS_MONTH, $PROGRESS_BAR); +our (%WHERE_IS); $THIS_MONTH = to_yyyymm $^T; # Constants @@ -79,8 +78,8 @@ sub DEFAULT_OVERRIDE() { -t STDIN? OVERRIDE_ASK: OVERRIDE_FAIL; } use constant KEEP_ALL => "all"; use constant KEEP_RESTART => "restart"; use constant KEEP_DELETE => "delete"; -use constant KEEP_THISMONTH => "this-month"; -use constant DEFAULT_KEEP => KEEP_THISMONTH; +use constant KEEP_THIS_MONTH => "this-month"; +use constant DEFAULT_KEEP => KEEP_THIS_MONTH; # The file types use constant TYPE_PLAIN => "text/plain"; use constant TYPE_GZIP => "application/x-gzip"; @@ -89,19 +88,18 @@ use constant TYPE_BZIP2 => "application/x-bzip2"; use constant TMP_SUFFIX => ".tmp-arclog"; use constant GZIP_SUFFIX => ".gz"; use constant BZIP2_SUFFIX => ".bz2"; -use constant DEFAULT_PROGBAR => 1; +use constant DEFAULT_IS_PROGRESS_BAR => 1; use constant DEFAULT_SORT => 0; -use vars qw($VERMSG $HELPMSG); -our $SHORTHELP; -$VERMSG = "$THIS_FILE v$VERSION by imacat "; -$SHORTHELP = "Try `$THIS_FILE --help' for more information."; -$HELPMSG = << "EOT"; +our ($VER_MSG, $HELP_MSG, $SHORT_HELP); +$VER_MSG = "$THIS_FILE v$VERSION by imacat "; +$SHORT_HELP = "Try `$THIS_FILE --help' for more information."; +$HELP_MSG = << "EOT"; Usage: $THIS_FILE [options] logfile... [output] Archive the log files monthly. logfile The log file to be archived. - output The prefix of the output files. The output files will be + output The prefix of the output files. The output files are named as pre.yyyymm, ie: pre.200001, pre.200002. If not specified, the default prefix is the logfile pathname. --compress method Compress the archived files. Available methods are: @@ -126,14 +124,14 @@ EOT main; exit 0; -# main: Main program +# Main program sub main() { local ($_, %_); my %ARC; - + # Parse the arguments parse_args; - + # Create the temporary working files $_->create_temp foreach @LOGFILES; # Read the source files to temporary working files @@ -143,27 +141,27 @@ sub main() { foreach my $logfile (@LOGFILES) { my ($label, $count, $dropped); print STDERR "Archiving " . $logfile->{"file"} . " ... " - if $VERBOSE > 0 && !$CONF{"PROGBAR"}; - print STDERR "\n" if $VERBOSE > 1 && !$CONF{"PROGBAR"}; + if $VERBOSE > 0 && !$CONF{"IS_PROGRESS_BAR"}; + print STDERR "\n" if $VERBOSE > 1 && !$CONF{"IS_PROGRESS_BAR"}; $label = $logfile->{"file"}; $label = "-" . substr($label, -13) if length $label > 14; ($count, $dropped) = (0, 0); - if ($CONF{"PROGBAR"}) { - $PROGBAR = _private::ProgressBar->new($label, $logfile->{"count"}); - $PROGBAR->update(0); + if ($CONF{"IS_PROGRESS_BAR"}) { + $PROGRESS_BAR = _private::ProgressBar->new($label, $logfile->{"count"}); + $PROGRESS_BAR->update(0); } # Sort each log record by month while (defined($_ = $logfile->read_record)) { - my ($month, $FH); + my $month; $month = $logfile->{"format"}->parse_month($_); # Skip malformed records whose time is not parsable if (!defined $month) { $dropped++; - + # This month to keep - } elsif ($CONF{"KEEP"} eq KEEP_THISMONTH && $month eq $THIS_MONTH) { + } elsif ($CONF{"KEEP"} eq KEEP_THIS_MONTH && $month eq $THIS_MONTH) { $logfile->save_this_month($_); - + # Months to archive } else { # A new month @@ -172,11 +170,11 @@ sub main() { $ARC{$month}->add($_) if !$ARC{$month}->{"ignore"}; } $count++; - $PROGBAR->update($count) if $CONF{"PROGBAR"}; + $PROGRESS_BAR->update($count) if $CONF{"IS_PROGRESS_BAR"}; } - undef $PROGBAR if $CONF{"PROGBAR"}; + undef $PROGRESS_BAR if $CONF{"IS_PROGRESS_BAR"}; print STDERR "$count records\n" - if $VERBOSE > 0 && !$CONF{"PROGBAR"}; + if $VERBOSE > 0 && !$CONF{"IS_PROGRESS_BAR"}; warn "Dropping $dropped malformed records\n" if $dropped > 0; } @@ -191,12 +189,12 @@ sub main() { $ARC{$month}->store_archive; } # Return the records of this month - if ($CONF{"KEEP"} eq KEEP_THISMONTH) { + if ($CONF{"KEEP"} eq KEEP_THIS_MONTH) { $_->restore_this_month foreach @LOGFILES; } # Remove the temporarily working files $_->remove_temp foreach @LOGFILES; - + # Print the statistics printf STDERR "%d archive files written, %d seconds elapsed.\n", scalar(grep !$ARC{$_}->{"ignore"}, keys %ARC), (time - $^T) @@ -204,11 +202,11 @@ sub main() { return; } -# parse_args: Parse the arguments +# Parse the arguments sub parse_args() { local ($_, %_); my ($has_stdin, $one_arg); - + %CONF = qw(); $CONF{"SORT"} = DEFAULT_SORT; # Get the arguments @@ -249,30 +247,30 @@ sub parse_args() { } elsif ($_[1] =~ /^(?:d|delete)$/i) { $CONF{"KEEP"} = KEEP_DELETE; } elsif ($_[1] =~ /^(?:t|this-month)$/i) { - $CONF{"KEEP"} = KEEP_THISMONTH; + $CONF{"KEEP"} = KEEP_THIS_MONTH; } else { die "$THIS_FILE: Unknown keep mode: $_[1]\n"; } }, "debug|d+"=>\$VERBOSE, "quiet|q"=>sub { $VERBOSE-- if $VERBOSE > 0; }, - "help|h"=>sub { print $HELPMSG; exit 0; }, - "version|v"=>sub { print "$VERMSG\n"; exit 0; }); + "help|h"=>sub { print $HELP_MSG; exit 0; }, + "version|v"=>sub { print "$VER_MSG\n"; exit 0; }); }; - die "$THIS_FILE: $@$SHORTHELP\n" if $@ ne ""; - + die "$THIS_FILE: $@$SHORT_HELP\n" if $@ ne ""; + # Save the original STDIN and STDOUT open $STDIN, "<&", \*STDIN or die "$THIS_FILE: STDIN: $!"; open $STDOUT, ">&", \*STDOUT or die "$THIS_FILE: STDOUT: $!"; - + # Set the verbose level autoflush STDERR if $VERBOSE > 1; - $CONF{"PROGBAR"} = DEFAULT_PROGBAR; - $CONF{"PROGBAR"} = 0 if $VERBOSE == 0 || !-t STDERR; - if ($CONF{"PROGBAR"}) { + $CONF{"IS_PROGRESS_BAR"} = DEFAULT_IS_PROGRESS_BAR; + $CONF{"IS_PROGRESS_BAR"} = 0 if $VERBOSE == 0 || !-t STDERR; + if ($CONF{"IS_PROGRESS_BAR"}) { # Check if we have Term::ReadKey - $CONF{"PROGBAR"} = 0 unless eval { require Term::ReadKey; 1; }; + $CONF{"IS_PROGRESS_BAR"} = 0 unless eval { require Term::ReadKey; 1; }; } - + # Check the arguments # Arguments are source files @LOGFILES = qw(); @@ -283,38 +281,38 @@ sub parse_args() { push @LOGFILES, $_; $_{$_} = 1; } - die "$THIS_FILE: Which log file do you want to archive?\n$SHORTHELP\n" + die "$THIS_FILE: Which log file do you want to archive?\n$SHORT_HELP\n" if @LOGFILES == 0; $has_stdin = scalar grep $_ eq "-", @LOGFILES; # The output prefix $one_arg = (@LOGFILES == 1); if ($one_arg) { # STDIN must specify the output prefix - die "$THIS_FILE: You must specify the output prefix for STDIN\n$SHORTHELP\n" + die "$THIS_FILE: You must specify the output prefix for STDIN\n$SHORT_HELP\n" if $LOGFILES[0] eq "-"; $CONF{"OUTPUT"} = $LOGFILES[0]; } else { $CONF{"OUTPUT"} = pop @LOGFILES; - die "$THIS_FILE: You cannot specify STDOUT as the output prefix\n$SHORTHELP\n" + die "$THIS_FILE: You cannot specify STDOUT as the output prefix\n$SHORT_HELP\n" if $CONF{"OUTPUT"} eq "-"; } # Check the duplicates - after removing the output prefix %_ = qw(); foreach (@LOGFILES) { - die "$THIS_FILE: $_: You can only specify a file once\n$SHORTHELP\n" + die "$THIS_FILE: $_: You can only specify a file once\n$SHORT_HELP\n" if exists $_{$_}; $_{$_} = 1; } - + # Set the default override mode $CONF{"OVERRIDE"} = DEFAULT_OVERRIDE if !exists $CONF{"OVERRIDE"}; # Set the default keep mode $CONF{"KEEP"} = DEFAULT_KEEP if !exists $CONF{"KEEP"}; # Set the default compress mode $CONF{"COMPRESS"} = DEFAULT_COMPRESS if !exists $CONF{"COMPRESS"}; - + # Cannot keep the records of this month back in STDIN - if ($has_stdin && $CONF{"KEEP"} eq KEEP_THISMONTH) { + if ($has_stdin && $CONF{"KEEP"} eq KEEP_THIS_MONTH) { warn "$THIS_FILE: Cannot keep this-month in STDIN. Change to keep all.\n"; $CONF{"KEEP"} = KEEP_ALL; } @@ -333,9 +331,9 @@ sub parse_args() { warn "$THIS_FILE: Cannot read from STDIN in ask mode. Change to fail mode.\n"; $CONF{"OVERRIDE"} = "fail"; } - + # Check the log files - @LOGFILES = map new _private::LogFile($_), @LOGFILES; + @LOGFILES = map _private::LogFile->new($_), @LOGFILES; if ((@_ = grep $_->{"is_empty"}, @LOGFILES) > 0) { print STDERR "Skipping empty files: " . join(", ", map $_->{"file"}, @_) . "\n" if $VERBOSE > 0; @@ -360,53 +358,53 @@ sub parse_args() { @LOGFILES if keys %_ > 1; $CONF{"FORMAT"} = $LOGFILES[0]->{"format"}; - + # Check the output file prefix # Strip the filename suffix of the compressed files if ($one_arg) { $CONF{"OUTPUT"} =~ s/\.gz$// if $LOGFILES[0]->{"type"} eq TYPE_GZIP; $CONF{"OUTPUT"} =~ s/\.bz2$// if $LOGFILES[0]->{"type"} eq TYPE_BZIP2; } - die "$THIS_FILE: Please specify output prefix\n$SHORTHELP\n" + die "$THIS_FILE: Please specify output prefix\n$SHORT_HELP\n" if !defined $CONF{"OUTPUT"}; $CONF{"OUTPUT"} = rel2abs $CONF{"OUTPUT"}; $_ = (fileparse $CONF{"OUTPUT"})[1]; - die "$THIS_FILE: $_: Not found\n$SHORTHELP\n" + die "$THIS_FILE: $_: Not found\n$SHORT_HELP\n" if !-e $_; - die "$THIS_FILE: $_: Not a directory\n$SHORTHELP\n" + die "$THIS_FILE: $_: Not a directory\n$SHORT_HELP\n" if !-d $_; - die "$THIS_FILE: $_: Permission denied\n$SHORTHELP\n" + die "$THIS_FILE: $_: Permission denied\n$SHORT_HELP\n" if !-w $_; - + return; } -# whereis: Find an executable +# Find an executable # Code inspired from CPAN::FirstTime -sub whereis($) { +sub where_is($) { local ($_, %_); my ($file, $path); $file = $_[0]; - return $WHEREIS{$file} if exists $WHEREIS{$file}; + return $WHERE_IS{$file} if exists $WHERE_IS{$file}; foreach my $dir (path) { print STDERR " Checking $dir ... " if $VERBOSE > 3; if (defined($path = MM->maybe_command(catfile($dir, $file)))) { print STDERR "$path\n found " if $VERBOSE > 3; - return ($WHEREIS{$file} = $path); + return ($WHERE_IS{$file} = $path); } print STDERR "no\n" if $VERBOSE > 3; } - return ($WHEREIS{$file} = undef); + return ($WHERE_IS{$file} = undef); } -# to_yyyymm: convert timestamp to yyyymm +# convert timestamp to yyyymm sub to_yyyymm($) { local ($_, %_); @_ = localtime $_[0]; return sprintf "%04d%02d", $_[5] + 1900, $_[4] + 1; } -# format_number: Format the number every 3 digit +# Format the number every 3 digit sub format_number($) { local $_; $_ = $_[0]; @@ -415,16 +413,16 @@ sub format_number($) { return $_; } -# rel2abs: Convert a relative path to an absolute path +# Convert a relative path to an absolute path sub rel2abs($;$) { local ($_, %_); my ($path, $base); ($path, $base) = @_; - + # Turn the base absolute $base = cwd unless defined $base; $base = rel2abs $base if !file_name_is_absolute $base; - + # Deal with the ~ user home directories under UNIX if (defined $Config::Config{"d_getpwent"}) { @_ = splitdir($path); @@ -449,10 +447,10 @@ sub rel2abs($;$) { $path = catfile @_; } } - + # Append the current directory if relative $path = catfile($base, $path) unless file_name_is_absolute $path; - + @_ = splitdir($path); # Split into directory components # Add an empty filename level if last level is a directory push @_, "" if ($_[@_-1] eq curdir || $_[@_-1] eq updir); @@ -472,13 +470,13 @@ sub rel2abs($;$) { } -# _private::ProgressBar: The progress bar displayer +# _private::ProgressBar: The progress bar display package _private::ProgressBar; use 5.008; use strict; use warnings; -# new: Initialize the progrss bar handler +# Initialize the progress bar handler sub new : method { local ($_, %_); my ($class, $self, $label, $total); @@ -487,18 +485,18 @@ sub new : method { $self->{"label"} = $label; $self->{"total"} = $total; $self->{"start"} = time; - $self->{"lastline"} = undef; + $self->{"last_line"} = undef; require Term::ReadKey; return $self; } -# update: Update the progress bar +# Update the progress bar sub update : method { local ($_, %_); my ($self, $cur, $label, $width, $elapsed, $min, $sec, $bar, $line); ($self, $cur, $label) = @_; $label = $self->{"label"} if !defined $label; - + # Not enough space for a progress bar return if ($width = (Term::ReadKey::GetTerminalSize())[0] - 30) < 1; # Calculate the elapsed time @@ -511,11 +509,11 @@ sub update : method { $line = sprintf "\r%-14.14s [%-".$width."s] %3.0f%% %02d:%02d", $label, $bar, ($cur / $self->{"total"}) * 100, $min, $sec; # Print if changed - if (!defined $self->{"lastline"} || $self->{"lastline"} ne $line) { + if (!defined $self->{"last_line"} || $self->{"last_line"} ne $line) { # Print it print STDERR "\r$line"; # Record the current line - $self->{"lastline"} = $line; + $self->{"last_line"} = $line; } # Finished print STDERR "\n" if $cur == $self->{"total"}; @@ -542,35 +540,35 @@ use constant MAGIC_PM => "File::MMagic"; use constant MAGIC_EXEC => "file"; use constant MAGIC_SUFFIX => "suffix"; -use vars qw($MAGIC_METHOD $MAGIC); +our ($MAGIC_METHOD, $MAGIC); BEGIN { undef $MAGIC_METHOD; undef $MAGIC; } -# new: Initialize the source log file processer +# Initialize the source log file processor sub new : method { local ($_, %_); my ($class, $self, $file, $FH, $f0); ($class, $file) = @_; - + # STDIN is another class if ($file eq "-") { $class .= "::STDIN"; return $class->new(@_[1...$#_]); } - + $self = bless {}, $class; $self->{"stdin"} = 0; $self->{"keep"} = $CONF{"KEEP"}; $self->{"override"} = $CONF{"OVERRIDE"}; $self->{"tmp"} = undef; - + # Load the File::MMagic first before opening anything, or the seek # method will not be loaded into IO::Handle $self->check_magic; - $self->{"checktype"} = $file if $MAGIC_METHOD eq MAGIC_EXEC; - + $self->{"check_type"} = $file if $MAGIC_METHOD eq MAGIC_EXEC; + $self->{"file"} = rel2abs $file; ($f0, $file) = ($file, $self->{"file"}); # Open the file @@ -582,7 +580,7 @@ sub new : method { flock $FH, LOCK_EX; } $self->{"FH"} = $FH; - + # Check the file type print STDERR "Checking file type of $f0 ... " if $VERBOSE > 1; $self->{"type"} = $self->check_type; @@ -591,29 +589,29 @@ sub new : method { $self->{"io"} = $self->check_io; # Open the file $self->{"io"}->open_read($file, $self->{"FH"}); - # Check the log file fromat + # Check the log file format $self->{"format"} = $self->check_format; # Not empty if (!$self->{"is_empty"}) { # Check the temporarily working file availability $self->{"temp"} = $self->check_temp; } - + return $self; } -# check_temp: Check the temporarily working file availability +# Check the temporarily working file availability sub check_temp : method { local ($_, %_); my ($self, $file, $dir, $suf); $self = $_[0]; - + # No need to create a named temporarily file if we keep the log file if ($CONF{"KEEP"} eq KEEP_ALL) { # Create an anonymous temporary file return undef; } - + if ($self->{"type"} eq TYPE_GZIP) { ($file, $dir, $suf) = fileparse $self->{"file"}, ".gz"; } elsif ($self->{"type"} eq TYPE_BZIP2) { @@ -621,29 +619,29 @@ sub check_temp : method { } else { ($file, $dir, $suf) = fileparse $self->{"file"}; } - + $_ = $dir . $file . TMP_SUFFIX; # Does the temporary working file exists? - die "$THIS_FILE: $_: Temporary working file exists\n$SHORTHELP\n" + die "$THIS_FILE: $_: Temporary working file exists\n$SHORT_HELP\n" if -e $_; - + # Check if we can create the temporarily working file - die "$THIS_FILE: $dir: File exists\n$SHORTHELP\n" + die "$THIS_FILE: $dir: File exists\n$SHORT_HELP\n" if !-e $dir; - die "$THIS_FILE: $dir: Not a directory\n$SHORTHELP\n" + die "$THIS_FILE: $dir: Not a directory\n$SHORT_HELP\n" if !-d $dir; - die "$THIS_FILE: $dir: Permission denied\n$SHORTHELP\n" + die "$THIS_FILE: $dir: Permission denied\n$SHORT_HELP\n" if !-w $dir; - + return $_; } -# check_format: Check the log file fromat +# Check the log file format sub check_format : method { local ($_, %_); my $self; $self = $_[0]; - + # Read the first line from the source file $self->{"first_line"} = $self->{"io"}->readline; # Skip empty files @@ -652,7 +650,7 @@ sub check_format : method { print STDERR "File is empty.\n" if $VERBOSE > 1; return undef; } - + # Check the log file format print STDERR "Checking the log file format... " if $VERBOSE > 1; print STDERR "\n" if $VERBOSE > 2; @@ -666,12 +664,12 @@ sub check_format : method { return $_; } -# create_temp: Create the temporary working file +# Create the temporary working file sub create_temp : method { local ($_, %_); my ($self, $temp, $FHT); $self = $_[0]; - + # Create a named temporarily working file if (defined $self->{"temp"}) { $temp = $self->{"temp"}; @@ -681,7 +679,7 @@ sub create_temp : method { $self->{"FHT"} = $FHT; print STDERR "done\n" if $VERBOSE > 2; return $FHT; - + # Create an anonymous temporarily working file } else { print STDERR "Creating temporary working file for " . $self->{"file"} . " ... " @@ -693,7 +691,7 @@ sub create_temp : method { } } -# remove_temp: Remove the temporary working file +# Remove the temporary working file sub remove_temp : method { local ($_, %_); my ($self, $temp, $FHT); @@ -705,7 +703,7 @@ sub remove_temp : method { close $FHT or die "$THIS_FILE: $temp: $!"; unlink $temp or die "$THIS_FILE: $temp: $!"; print STDERR "done\n" if $VERBOSE > 2; - + # An anonymous temporarily working file } else { print STDERR "Closing temporary working file ... " if $VERBOSE > 2; @@ -715,7 +713,7 @@ sub remove_temp : method { return; } -# read_source: Read the source file +# Read the source file sub read_source : method { local ($_, %_); my ($self, $file, $FHT, $count); @@ -741,10 +739,10 @@ sub read_source : method { return $count;; } -# read_record: Read a record, returning the record and its month +# Read a record, returning the record and its month sub read_record : method { local ($_, %_); - my ($self, $FHT, $record, $month); + my ($self, $FHT); $self = $_[0]; $FHT = $self->{"FHT"}; # Reset when start reading @@ -758,65 +756,65 @@ sub read_record : method { return $_; } -# save_this_month: Save the records of this month +# Save the records of this month sub save_this_month : method { local ($_, %_); my ($self, $record, $FH); ($self, $record) = @_; # Create the temporary saving space - if (!exists $self->{"FHTH"}) { - print STDERR "\n" if $VERBOSE > 2 && defined $PROGBAR; + if (!exists $self->{"FH_TM"}) { + print STDERR "\n" if $VERBOSE > 2 && defined $PROGRESS_BAR; print STDERR " Creating buffer for this month ... " if $VERBOSE > 2; $FH = tempfile or die "$THIS_FILE: tempfile: $!"; flock $FH, LOCK_EX or die "$THIS_FILE: tempfile: $!"; print STDERR "done\n" if $VERBOSE > 2; - $self->{"FHTH"} = $FH; - $self->{"count_thismonth"} = 0; - $self->{"size_thismonth"} = 0; + $self->{"FH_TM"} = $FH; + $self->{"count_this_month"} = 0; + $self->{"size_this_month"} = 0; } else { - $FH = $self->{"FHTH"}; + $FH = $self->{"FH_TM"}; } # Save the record print $FH $record or die "$THIS_FILE: tempfile: $!"; - $self->{"count_thismonth"}++; - $self->{"size_thismonth"} += length $record; + $self->{"count_this_month"}++; + $self->{"size_this_month"} += length $record; return; } -# restore_this_month: Return the records of this month to the log file +# Return the records of this month to the log file sub restore_this_month : method { local ($_, %_); - my ($self, $file, $FH, $count); + my ($self, $file, $FH); $self = $_[0]; # Bounce if no record to restore - return unless exists $self->{"FHTH"}; - ($file, $FH) = ($self->{"file"}, $self->{"FHTH"}); - + return unless exists $self->{"FH_TM"}; + ($file, $FH) = ($self->{"file"}, $self->{"FH_TM"}); + # Prepend the records using the I/O class implementation ref($self->{"io"})->prepend_records($file, $FH); - + # Report the statistics printf STDERR "%s: keeping %s records, %s bytes\n", - $file, format_number($self->{"count_thismonth"}), - format_number($self->{"size_thismonth"}) + $file, format_number($self->{"count_this_month"}), + format_number($self->{"size_this_month"}) if $VERBOSE > 0; - + return; } -# check_type: Check the source file type +# Check the source file type sub check_type : method { local ($_, %_); my ($self, $file, $FH, $PH, $CMD); $self = $_[0]; ($file, $FH) = ($self->{"file"}, $self->{"FH"}); - + # Check the file type checker to use $self->check_magic; die "$THIS_FILE: Cannot check STDIN from the filename suffix.\n" if $self->{"stdin"} && $MAGIC_METHOD eq MAGIC_SUFFIX; - + # Check by file name suffix # Check by file name suffix on empty files, too. # Compress::Bzip2 2 creates empty files that confuses further processing. @@ -826,17 +824,17 @@ sub check_type : method { # Otherwise we assume it to be text/plain return TYPE_PLAIN; } - + # Check the file format # Check by File::MMagic if ($MAGIC_METHOD eq MAGIC_PM) { $_ = $MAGIC->checktype_filehandle($FH); seek $FH, 0, SEEK_SET or die "$THIS_FILE: $file: $!"; - + # Check by the file program } elsif ($MAGIC_METHOD eq MAGIC_EXEC) { flock $FH, LOCK_UN; - @_ = ($MAGIC, $self->{"checktype"}); + @_ = ($MAGIC, $self->{"check_type"}); @_ = map "\"$_\"", @_ if $^O eq "MSWin32"; $CMD = join " ", @_; # Start the process @@ -853,7 +851,7 @@ sub check_type : method { flock $FH, LOCK_EX; } } - + # Check the returned file type text return TYPE_GZIP if /gzip/i; return TYPE_BZIP2 if /bzip2/i; @@ -861,7 +859,7 @@ sub check_type : method { return TYPE_PLAIN; } -# check_io: Check the I/O handler to use +# Check the I/O handler to use sub check_io : method { local ($_, %_); my $self; @@ -874,15 +872,15 @@ sub check_io : method { return _private::IO::Plain->new; } -# check_magic: Check the file type checker to use +# Check the file type checker to use sub check_magic : method { local ($_, %_); my $self; $self = $_[0]; - + # Checked before return $MAGIC_METHOD if defined $MAGIC_METHOD; - + print STDERR "Checking file type checker to use ... " if $VERBOSE > 1; print STDERR "\n Checking File::MMagic ... " if $VERBOSE > 2; # Check if we have File::MMagic @@ -896,11 +894,11 @@ sub check_magic : method { print STDERR "no\n" if $VERBOSE > 2; $@ =~ s/^(Can't locate \S+ in \@INC).*\n/$1\n/; # ' warn "$@" if $VERBOSE == 1; - + # Looking for file from PATH print STDERR " Checking file ... " if $VERBOSE > 2; # Found in PATH - if (defined($MAGIC = whereis "file")) { + if (defined($MAGIC = where_is "file")) { print STDERR "$MAGIC\nfound " if $VERBOSE > 2; print STDERR "$MAGIC\n" if $VERBOSE > 1; warn "$THIS_FILE: We will check with $MAGIC instead\n" @@ -909,7 +907,7 @@ sub check_magic : method { } # Not found print STDERR "no\n" if $VERBOSE > 2; - + # Check by file name suffix print STDERR " Fall back using file name suffix instead\n" if $VERBOSE > 2; print STDERR "file name suffix\n" if $VERBOSE > 1; @@ -933,31 +931,31 @@ use IO::Handle; use Fcntl qw(:flock :seek); use File::Temp qw(tempfile unlink0); -# new: Initialize the source log file processer +# Initialize the source log file processor sub new : method { local ($_, %_); my ($class, $self, $file, $FH, $tmp); ($class, $file) = @_; - + # We only initialize STDIN return $file if ref($file) ne "" || $file ne "-"; - + $self = bless {}, $class; $self->{"stdin"} = 1; $self->{"keep"} = KEEP_ALL; $self->{"override"} = OVERRIDE_OVERWRITE; $self->{"tmp"} = undef; - + # Load the File::MMagic first before opening anything, or the seek # method will not be loaded into IO::Handle $self->check_magic; - + # Save STDIN to somewhere $file = "the STDIN buffer"; if ($_private::LogFile::MAGIC_METHOD eq _private::LogFile::MAGIC_EXEC) { ($FH, $tmp) = tempfile(undef, UNLINK => 1) or die "$THIS_FILE: tempfile: $!"; - $self->{"checktype"} = $tmp; + $self->{"check_type"} = $tmp; $self->{"tmp"} = $tmp; } else { undef $tmp; @@ -971,7 +969,7 @@ sub new : method { } seek $FH, 0, SEEK_SET or die "$THIS_FILE: $file: $!"; print STDERR "done\n" if $VERBOSE > 1; - + # Check the file type print STDERR "Checking file type of STDIN ... " if $VERBOSE > 1; $self->{"type"} = $self->check_type; @@ -984,15 +982,15 @@ sub new : method { $self->{"io"} = $self->check_io; # Open the file $self->{"io"}->open_read($file, $self->{"FH"}); - # Check the log file fromat + # Check the log file format $self->{"format"} = $self->check_format; # STDIN always goes to an anonymous temporarily working file $self->{"temp"} = undef; - + return $self; } -# remove_temp: Remove the temporary working file +# Remove the temporary working file sub remove_temp : method { local ($_, %_); $_ = $_[0]; @@ -1017,7 +1015,7 @@ use Fcntl qw(:flock :seek); use File::Basename qw(basename); use File::Temp qw(tempfile); -# new: Initialize the result archive file processer +# Initialize the result archive file processor sub new : method { local ($_, %_); my ($class, $self, $month, $file, $FH); @@ -1043,13 +1041,13 @@ sub new : method { # If we should ask # Jump off the progress bar print STDERR "\n" - if $self->{"override"} eq OVERRIDE_ASK && defined $PROGBAR; + if $self->{"override"} eq OVERRIDE_ASK && defined $PROGRESS_BAR; while ($self->{"override"} eq OVERRIDE_ASK) { - printf STDERR "$file exists, (O)verwrite, (A)ppend, (I)gnore, (F)ail? [F] "; + printf STDERR "$file exists, (O)overwrite, (A)append, (I)ignore, (F)fail? [F] "; $_ = ; # Fail if not answered if (!defined $_) { - print STDERR "\nArhh.. you are not here. I had better drop it right now.\n"; + print STDERR "\nhat.. you are not here. I had better drop it right now.\n"; $self->{"override"} = OVERRIDE_FAIL; last; } @@ -1081,14 +1079,14 @@ sub new : method { } elsif ($self->{"override"} eq OVERRIDE_FAIL) { die "$THIS_FILE: $file: Output file exists\n"; } - + # Not exists - we always create it } else { $self->{"override"} = OVERRIDE_OVERWRITE; } - # The temporary log record backet + # The temporary log record bucket if (!$self->{"ignore"}) { - print STDERR "\n" if $VERBOSE > 2 && defined $PROGBAR; + print STDERR "\n" if $VERBOSE > 2 && defined $PROGRESS_BAR; print STDERR " Creating buffer for $month ... " if $VERBOSE > 2; $FH = tempfile or die "$THIS_FILE: tempfile: $!"; @@ -1096,31 +1094,31 @@ sub new : method { $self->{"FH"} = $FH; print STDERR "done\n" if $VERBOSE > 2; } - $self->{"sizeorig"} = 0; + $self->{"size_original"} = 0; return $self; } -# add: Add a record to the temporarily archive file +# Add a record to the temporarily archive file sub add : method { local ($_, %_); my ($self, $FH); ($self, $_) = @_; $FH = $self->{"FH"}; print $FH $_ or die "$THIS_FILE: tempfile: $!"; - $self->{"sizeorig"} += length $_; + $self->{"size_original"} += length $_; return; } -# sort: Sort the records +# Sort the records sub sort : method { local ($_, %_); my ($self, $FH0, $FH1, $month, $count, $pos, $t, @recs); $self = $_[0]; ($FH0, $month) = ($self->{"FH"}, $self->{"month"}); - + print STDERR "Sorting records of $month ... " if $VERBOSE > 1; print STDERR "\n" if $VERBOSE > 2; - + # Obtain the information of each record print STDERR " Obtain the time and position of the records ... " if $VERBOSE > 2; @@ -1135,13 +1133,13 @@ sub sort : method { ($pos = tell $FH0) != -1 or die "$THIS_FILE: tempfile: $!"; } print STDERR "$count records\n" if $VERBOSE > 2; - + # Sort by time and then original order print STDERR " Sorting the records by time ... " if $VERBOSE > 2; @recs = CORE::sort { $$a{"time"} <=> $$b{"time"} || $$a{"pos"} <=> $$b{"pos"} } @recs; print STDERR "done\n" if $VERBOSE > 2; - + # Store the records according to the new order print STDERR " Creating new buffer for $month ... " if $VERBOSE > 2; $FH1 = tempfile or die "$THIS_FILE: tempfile: $!"; @@ -1157,19 +1155,19 @@ sub sort : method { $count++; } print STDERR "$count records\n" if $VERBOSE > 2; - + # Use the new buffer instead of the old one print STDERR " Switching to the new buffer ... " if $VERBOSE > 2; flock $FH0, LOCK_UN or die "$THIS_FILE: tempfile: $!"; close $FH0 or die "$THIS_FILE: tempfile: $!"; $self->{"FH"} = $FH1; print STDERR "done\n" if $VERBOSE > 2; - + print STDERR "$count records\n" if $VERBOSE > 1; return; } -# store_archive: Store the archived log records +# Store the archived log records sub store_archive : method { local ($_, %_); my ($self, $FH, $file, $count); @@ -1179,18 +1177,18 @@ sub store_archive : method { seek $FH, 0, SEEK_SET or die "$THIS_FILE: tempfile: $!"; # Overwrite if ($self->{"override"} eq OVERRIDE_OVERWRITE) { - print STDERR "Outputing to $file ... " if $VERBOSE > 1; + print STDERR "Writing to $file ... " if $VERBOSE > 1; print STDERR "\n" if $VERBOSE > 2; $self->{"io"}->open_write($file); # Append } elsif ($self->{"override"} eq OVERRIDE_APPEND) { print STDERR "Appending to $file ... " if $VERBOSE > 1; print STDERR "\n" if $VERBOSE > 2; - $self->{"sizecomp"} = (stat $file)[7]; + $self->{"size_compressed"} = (stat $file)[7]; $self->{"io"}->open_append($file); } # Copy the data to the archive file - print STDERR " Outputing records ... " if $VERBOSE > 2; + print STDERR " Writing records ... " if $VERBOSE > 2; $count = 0; while (defined($_ = <$FH>)) { $self->{"io"}->write($_); @@ -1202,22 +1200,22 @@ sub store_archive : method { # Report the statistics # Overwrite if ($self->{"override"} eq OVERRIDE_OVERWRITE) { - $self->{"sizecomp"} = (stat $file)[7]; + $self->{"size_compressed"} = (stat $file)[7]; printf STDERR "%s: writing %s records, %s bytes, %s bytes, %0.2f%%\n", $self->{"month"}, format_number($count), - format_number($self->{"sizeorig"}), - format_number($self->{"sizecomp"}), - ($self->{"sizecomp"}*100/$self->{"sizeorig"}) + format_number($self->{"size_original"}), + format_number($self->{"size_compressed"}), + ($self->{"size_compressed"}*100/$self->{"size_original"}) if $VERBOSE > 0; - + # Append } elsif ($self->{"override"} eq OVERRIDE_APPEND) { - $self->{"sizecomp"} = (stat $file)[7] - $self->{"sizecomp"}; + $self->{"size_compressed"} = (stat $file)[7] - $self->{"size_compressed"}; printf STDERR "%s: adding %s records, %s bytes, %s bytes, %0.2f%%\n", $self->{"month"}, format_number($count), - format_number($self->{"sizeorig"}), - format_number($self->{"sizecomp"}), - ($self->{"sizecomp"}*100/$self->{"sizeorig"}) + format_number($self->{"size_original"}), + format_number($self->{"size_compressed"}), + ($self->{"size_compressed"}*100/$self->{"size_original"}) if $VERBOSE > 0; } return; @@ -1234,25 +1232,25 @@ import main; use Fcntl qw(:seek); -use vars qw($GZIP_IO $BZIP2_IO); +our ($GZIP_IO, $BZIP2_IO); BEGIN { undef $GZIP_IO; undef $BZIP2_IO; } -# new: Initialize the I/O handler interface +# Initialize the I/O handler interface sub new : method { bless {}, $_[0]; } -# suffix: The file name suffix of this mime type +# The file name suffix of this mime type sub suffix : method { ""; } -# check_gzip: Check for compression method of gzip +# Check for compression method of gzip sub check_gzip : method { local ($_, %_); - + # Checked before return ref($GZIP_IO)->new if defined $GZIP_IO; - + # See whether Compress::Zlib or gzip print STDERR "Checking gzip I/O handler to use ... " if $VERBOSE > 1; print STDERR "\n Checking Compress::Zlib ... " if $VERBOSE > 2; @@ -1265,29 +1263,29 @@ sub check_gzip : method { # Not found print STDERR "no\n" if $VERBOSE > 2; # It's OK not to warn - + # Looking for gzip from PATH print STDERR " Checking gzip... " if $VERBOSE > 2; # Found in PATH - if (defined($_ = whereis "gzip")) { + if (defined($_ = where_is "gzip")) { print STDERR "$_\nfound " if $VERBOSE > 2; print STDERR "$_\n" if $VERBOSE > 1; return ($GZIP_IO = _private::IO::Gzip::Exec->new); } # Not found print STDERR "no\n" if $VERBOSE > 2; - + print STDERR "not found\n" if $VERBOSE > 1; - die "$THIS_FILE: Necessary Compress::Zlib or gzip not available.\n$SHORTHELP\n"; + die "$THIS_FILE: Necessary Compress::Zlib or gzip not available.\n$SHORT_HELP\n"; } -# check_bzip2: Check for compression method of bzip2 +# Check for compression method of bzip2 sub check_bzip2 : method { local ($_, %_); - + # Checked before return ref($BZIP2_IO)->new if defined $BZIP2_IO; - + # See whether Compress::Bzip2 or bzip2 print STDERR "Checking bzip2 I/O handler to use ... " if $VERBOSE > 1; print STDERR "\n Checking Compress::Bzip2 ... " if $VERBOSE > 2; @@ -1300,23 +1298,23 @@ sub check_bzip2 : method { # Not found print STDERR "no\n" if $VERBOSE > 2; # It's OK not to warn - + # Looking for bzip2 from PATH print STDERR " Checking bzip2... " if $VERBOSE > 2; # Found in PATH - if (defined($_ = whereis "bzip2")) { + if (defined($_ = where_is "bzip2")) { print STDERR "$_\nfound " if $VERBOSE > 2; print STDERR "$_\n" if $VERBOSE > 1; return ($BZIP2_IO = _private::IO::Bzip2::Exec->new); } # Not found print STDERR "no\n" if $VERBOSE > 2; - + print STDERR "not found\n" if $VERBOSE > 1; - die "$THIS_FILE: Necessary Compress::Bzip2 or bzip2 not available.\n$SHORTHELP\n"; + die "$THIS_FILE: Necessary Compress::Bzip2 or bzip2 not available.\n$SHORT_HELP\n"; } -# prepend_records: Prepend records to an existing file +# Prepend records to an existing file # * static method * # For most I/O we read records out and write back with 2 I/O accesses. # But for plain text we need only open the file once. @@ -1325,7 +1323,7 @@ sub prepend_records : method { local ($_, %_); my ($class, $file, $FHT, $io, $count); ($class, $file, $FHT) = @_; - + # Read the current records (added after program execution) $io = $class->new; print STDERR "Reading new records from $file ... " if $VERBOSE > 1; @@ -1340,15 +1338,15 @@ sub prepend_records : method { print STDERR "$count records\n" if $VERBOSE > 2; $io->close; print STDERR "$count records\n" if $VERBOSE > 1; - - # Returing all the records + + # Returning all the records # Start a new I/O handler of the same class seek $FHT, 0, SEEK_SET or die "$THIS_FILE: tempfile: $!"; $io = $class->new; print STDERR "Returning all records to $file ... " if $VERBOSE > 1; print STDERR "\n" if $VERBOSE > 2; $io->open_write($file); - print STDERR " Outputing records ... " if $VERBOSE > 2; + print STDERR " Writing records ... " if $VERBOSE > 2; $count = 0; while (defined($_ = <$FHT>)) { $io->write($_); @@ -1357,7 +1355,7 @@ sub prepend_records : method { print STDERR "$count records\n" if $VERBOSE > 2; $io->close; print STDERR "$count records\n" if $VERBOSE > 1; - + return; } @@ -1374,7 +1372,7 @@ import main; use Fcntl qw(:flock :seek); -# open_read: Open the file for reading +# Open the file for reading sub open_read : method { local ($_, %_); my ($self, $file, $FH); @@ -1390,7 +1388,7 @@ sub open_read : method { return; } -# open_write: Open the file for writing +# Open the file for writing sub open_write : method { local ($_, %_); my ($self, $file, $FH); @@ -1406,7 +1404,7 @@ sub open_write : method { return; } -# open_append: Open the file for appending +# Open the file for appending sub open_append : method { local ($_, %_); my ($self, $file, $FH); @@ -1422,7 +1420,7 @@ sub open_append : method { return; } -# readline: Read a line from the I/O stream +# Read a line from the I/O stream sub readline : method { local ($_, %_); my ($self, $FH); @@ -1431,7 +1429,7 @@ sub readline : method { return <$FH>; } -# write: Output data to the I/O stream +# Output data to the I/O stream sub write : method { local ($_, %_); my ($self, $file, $FH); @@ -1441,27 +1439,27 @@ sub write : method { return; } -# close: Close the I/O stream +# Close the I/O stream sub close : method { local ($_, %_); my ($self, $keep, $tmp, $file, $FH); ($self, $keep, $tmp) = @_; $keep = KEEP_ALL if @_ < 2; ($file, $FH) = ($self->{"file"}, $self->{"FH"}); - + # Restart the file - if ($keep eq KEEP_RESTART || $keep eq KEEP_THISMONTH) { + if ($keep eq KEEP_RESTART || $keep eq KEEP_THIS_MONTH) { # Empty the source file print STDERR " Emptying file ... " if $VERBOSE > 2; seek $FH, 0, SEEK_SET or die "$THIS_FILE: $file: $!"; truncate $FH, 0 or die "$THIS_FILE: $file: $!"; print STDERR "done\n" if $VERBOSE > 2; } - + CORE::close $FH or die "$THIS_FILE: $file: $!"; delete $self->{"FH"}; delete $self->{"file"}; - + # Delete the file if ($keep eq KEEP_DELETE) { print STDERR " Deleting file ... " if $VERBOSE > 2; @@ -1475,23 +1473,23 @@ sub close : method { return; } -# prepend_records: Prepend records to an existing file +# Prepend records to an existing file # * static method * # Plain text version that only open the file once sub prepend_records : method { local ($_, %_); my ($class, $file, $FHT, $FHC, $count); ($class, $file, $FHT) = @_; - + # Read the current records (added after program execution) print STDERR "Reading new records from $file ... " if $VERBOSE > 1; print STDERR "\n" if $VERBOSE > 2; - + print STDERR " Opening file in read/write mode ... " if $VERBOSE > 2; open $FHC, "+<", $file or die "$THIS_FILE: $file: $!"; flock $FHC, LOCK_EX; print STDERR "done\n" if $VERBOSE > 2; - + # Read the new records print STDERR " Reading new records ... " if $VERBOSE > 2; $count = 0; @@ -1500,24 +1498,24 @@ sub prepend_records : method { $count++; } print STDERR "$count records\n" if $VERBOSE > 2; - + # Reset the reader/writer seek $FHT, 0, SEEK_SET or die "$THIS_FILE: tempfile: $!"; seek $FHC, 0, SEEK_SET or die "$THIS_FILE: $file: $!"; truncate $FHC, 0 or die "$THIS_FILE: $file: $!"; - + # Return all the records - print STDERR " Outputing records ... " if $VERBOSE > 2; + print STDERR " Writing records ... " if $VERBOSE > 2; $count = 0; while (defined($_ = <$FHT>)) { print $FHC $_ or die "$THIS_FILE: $file: $!"; $count++; } print STDERR "$count records\n" if $VERBOSE > 2; - + CORE::close $FHC or die "$THIS_FILE: $file: $!"; print STDERR "$count records\n" if $VERBOSE > 1; - + return; } @@ -1535,10 +1533,10 @@ import main; use Fcntl qw(:flock :seek); use File::Temp qw(tempfile); -# suffix: The file name suffix of this mime type +# The file name suffix of this mime type sub suffix : method { ".gz"; } -# open_read: Open the file for reading +# Open the file for reading sub open_read : method { local ($_, %_); my ($self, $file, $FH); @@ -1559,7 +1557,7 @@ sub open_read : method { return; } -# open_write: Open the file for writing +# Open the file for writing sub open_write : method { local ($_, %_); my ($self, $file, $FH); @@ -1580,7 +1578,7 @@ sub open_write : method { return; } -# open_append: Open the file for appending +# Open the file for appending sub open_append : method { local ($_, %_); my ($self, $file, $FH, $gz); @@ -1595,7 +1593,7 @@ sub open_append : method { } ($self->{"file"}, $self->{"FH"}) = ($file, $FH); import Compress::Zlib qw(gzopen); - + # Save the original data if file has content so that file size is # greater than 0. STDOUT is always of size 0. if ((stat $FH)[7] > 0) { @@ -1613,7 +1611,7 @@ sub open_append : method { seek $FH, 0, SEEK_SET or die "$THIS_FILE: $file: $!"; truncate $FH, 0 or die "$THIS_FILE: $file: $!"; print STDERR "done\n" if $VERBOSE > 2; - + # Decompress the buffer and save to our file print STDERR " Attaching buffer with gzopen(..., \"rb\") ... " if $VERBOSE > 2; $gzt = gzopen($FHT, "rb") or die "$THIS_FILE: tempfile: $!"; @@ -1621,7 +1619,7 @@ sub open_append : method { print STDERR " Attaching file with gzopen(..., \"wb9\") ... " if $VERBOSE > 2; $gz = gzopen($FH, "wb9") or die "$THIS_FILE: $file: $!"; print STDERR "done\n" if $VERBOSE > 2; - + print STDERR " Reading old records back from the buffer ... " if $VERBOSE > 2; $count = 0; while (($n = $gzt->gzreadline($_)) != 0) { @@ -1631,19 +1629,19 @@ sub open_append : method { } close $FHT or die "$THIS_FILE: tempfile: $!"; print STDERR "$count records\n" if $VERBOSE > 2; - + # A whole new file } else { print STDERR " Attaching file with gzopen(..., \"wb9\") ... " if $VERBOSE > 2; $gz = gzopen($FH, "wb9") or die "$THIS_FILE: $file: $!"; print STDERR "done\n" if $VERBOSE > 2; } - + $self->{"gz"} = $gz; return; } -# readline: Read a line from the I/O stream +# Read a line from the I/O stream sub readline : method { local ($_, %_); my ($self, $file, $gz, $n); @@ -1654,7 +1652,7 @@ sub readline : method { return $_; } -# write: Output data to the I/O stream +# Output data to the I/O stream sub write : method { local ($_, %_); my ($self, $file, $gz); @@ -1664,22 +1662,22 @@ sub write : method { return; } -# close: Close the I/O stream +# Close the I/O stream sub close : method { local ($_, %_); my ($self, $keep, $tmp, $file, $FH, $gz); ($self, $keep, $tmp) = @_; $keep = KEEP_ALL if @_ < 2; ($file, $FH, $gz) = ($self->{"file"}, $self->{"FH"}, $self->{"gz"}); - + # Restart the file - if ($keep eq KEEP_RESTART || $keep eq KEEP_THISMONTH) { + if ($keep eq KEEP_RESTART || $keep eq KEEP_THIS_MONTH) { # Empty the source file print STDERR " Emptying file ... " if $VERBOSE > 2; seek $FH, 0, SEEK_SET or die "$THIS_FILE: $file: $!"; truncate $FH, 0 or die "$THIS_FILE: $file: $!"; print STDERR "done\n" if $VERBOSE > 2; - + # Create empty compressed content print STDERR " Applying empty compressed content ... " if $VERBOSE > 2; $_ = gzopen($FH, "wb9") or die "$THIS_FILE: $file: $!"; @@ -1688,7 +1686,7 @@ sub close : method { undef $gz; print STDERR "done\n" if $VERBOSE > 2; } - + if (defined $gz) { $gz->gzclose and die "$THIS_FILE: $file: " . $gz->gzerror; } @@ -1696,7 +1694,7 @@ sub close : method { delete $self->{"gz"}; delete $self->{"FH"}; delete $self->{"file"}; - + # Delete the file if ($keep eq KEEP_DELETE) { print STDERR " Deleting file ... " if $VERBOSE > 2; @@ -1724,15 +1722,15 @@ import main; use Fcntl qw(:flock :seek); use File::Temp qw(tempfile); -use vars qw($EXEC); +our ($EXEC); BEGIN { undef $EXEC; } -# suffix: The file name suffix of this mime type +# The file name suffix of this mime type sub suffix : method { ".gz"; } -# open_read: Open the file for reading +# Open the file for reading sub open_read : method { local ($_, %_); my ($self, $file, $FH, $PH, $CMD); @@ -1747,8 +1745,8 @@ sub open_read : method { flock $FH, LOCK_UN; } ($self->{"file"}, $self->{"FH"}) = ($file, $FH); - $EXEC = whereis "gzip" if !defined $EXEC; - + $EXEC = where_is "gzip" if !defined $EXEC; + @_ = ($EXEC, "-cdf"); @_ = map "\"$_\"", @_ if $^O eq "MSWin32"; $CMD = join " ", @_; @@ -1768,7 +1766,7 @@ sub open_read : method { return; } -# open_write: Open the file for writing +# Open the file for writing sub open_write : method { local ($_, %_); my ($self, $file, $FH, $PH, $CMD); @@ -1783,8 +1781,8 @@ sub open_write : method { flock $FH, LOCK_UN; } ($self->{"file"}, $self->{"FH"}) = ($file, $FH); - $EXEC = whereis "gzip" if !defined $EXEC; - + $EXEC = where_is "gzip" if !defined $EXEC; + @_ = ($EXEC, "-c9f"); @_ = map "\"$_\"", @_ if $^O eq "MSWin32"; $CMD = join " ", @_; @@ -1804,7 +1802,7 @@ sub open_write : method { return; } -# open_append: Open the file for appending +# Open the file for appending sub open_append : method { local ($_, %_); my ($self, $file, $FH, $PH, $CMD); @@ -1819,12 +1817,12 @@ sub open_append : method { flock $FH, LOCK_UN; } ($self->{"file"}, $self->{"FH"}) = ($file, $FH); - $EXEC = whereis "gzip" if !defined $EXEC; - + $EXEC = where_is "gzip" if !defined $EXEC; + # Save the original data if file has content so that file size is # greater than 0. STDOUT is always of size 0. if ((stat $FH)[7] > 0) { - my ($count, $FHT, $PHT, $CMDT); + my ($count, $FHT, $PHT, $CMD_T); seek $FH, 0, SEEK_SET or die "$THIS_FILE: $file: $!"; # Copy the original content to a buffer print STDERR " Reading compressed data to the buffer ... " if $VERBOSE > 2; @@ -1838,24 +1836,24 @@ sub open_append : method { seek $FH, 0, SEEK_SET or die "$THIS_FILE: $file: $!"; truncate $FH, 0 or die "$THIS_FILE: $file: $!"; print STDERR "done\n" if $VERBOSE > 2; - + # Decompress the buffer and save to our file @_ = ($EXEC, "-cdf"); @_ = map "\"$_\"", @_ if $^O eq "MSWin32"; - $CMDT = join " ", @_; - print STDERR " Starting $CMDT from buffer ... " if $VERBOSE > 2; + $CMD_T = join " ", @_; + print STDERR " Starting $CMD_T from buffer ... " if $VERBOSE > 2; # Redirect STDIN to $FH open STDIN, "<&", $FHT or die "$THIS_FILE: tempfile: $!"; # Start the process if ($^O eq "MSWin32") { - open $PHT, "$CMDT |" or die "$THIS_FILE: $CMDT: $!"; + open $PHT, "$CMD_T |" or die "$THIS_FILE: $CMD_T: $!"; } else { - open $PHT, "-|", @_ or die "$THIS_FILE: $CMDT: $!"; + open $PHT, "-|", @_ or die "$THIS_FILE: $CMD_T: $!"; } # Restore STDIN open STDIN, "<&", $STDIN or die "$THIS_FILE: STDIN: $!"; print STDERR "done\n" if $VERBOSE > 2; - + @_ = ($EXEC, "-c9f"); @_ = map "\"$_\"", @_ if $^O eq "MSWin32"; $CMD = join " ", @_; @@ -1871,17 +1869,17 @@ sub open_append : method { # Restore STDOUT open STDOUT, ">&", $STDOUT or die "$THIS_FILE: STDOUT: $!"; print STDERR "done\n" if $VERBOSE > 2; - + print STDERR " Reading old records back from the buffer ... " if $VERBOSE > 2; $count = 0; while (defined($_ = <$PHT>)) { print $PH $_ or die "$THIS_FILE: $file: $!"; $count++; } - close $PHT or die "$THIS_FILE: $CMDT: $!"; + close $PHT or die "$THIS_FILE: $CMD_T: $!"; close $FHT or die "$THIS_FILE: tempfile: $!"; print STDERR "$count records\n" if $VERBOSE > 2; - + # A whole new file } else { @_ = ($EXEC, "-c9f"); @@ -1900,12 +1898,12 @@ sub open_append : method { open STDOUT, ">&", $STDOUT or die "$THIS_FILE: STDOUT: $!"; print STDERR "done\n" if $VERBOSE > 2; } - + ($self->{"CMD"}, $self->{"PH"}) = ([@_], $PH); return; } -# readline: Read a line from the I/O stream +# Read a line from the I/O stream sub readline : method { local ($_, %_); my ($self, $PH); @@ -1914,7 +1912,7 @@ sub readline : method { return <$PH>; } -# write: Output data to the I/O stream +# Output data to the I/O stream sub write : method { local ($_, %_); my ($self, $CMD, $PH); @@ -1924,25 +1922,25 @@ sub write : method { return; } -# close: Close the I/O stream +# Close the I/O stream sub close : method { local ($_, %_); my ($self, $keep, $tmp, $file, $FH, $CMD, $PH); ($self, $keep, $tmp) = @_; $keep = KEEP_ALL if @_ < 2; ($file, $FH) = ($self->{"file"}, $self->{"FH"}); - + # Restart the file - if ($keep eq KEEP_RESTART || $keep eq KEEP_THISMONTH) { + if ($keep eq KEEP_RESTART || $keep eq KEEP_THIS_MONTH) { # Empty the source file print STDERR " Emptying file ... " if $VERBOSE > 2; seek $FH, 0, SEEK_SET or die "$THIS_FILE: $file: $!"; truncate $FH, 0 or die "$THIS_FILE: $file: $!"; print STDERR "done\n" if $VERBOSE > 2; - + # Create empty compressed content print STDERR " Applying empty compressed content ... " if $VERBOSE > 2; - $EXEC = whereis "gzip" if !defined $EXEC; + $EXEC = where_is "gzip" if !defined $EXEC; @_ = ($EXEC, "-c9f"); @_ = map "\"$_\"", @_ if $^O eq "MSWin32"; $CMD = join " ", @_; @@ -1959,7 +1957,7 @@ sub close : method { open STDOUT, ">&", $STDOUT or die "$THIS_FILE: STDOUT: $!"; print STDERR "done\n" if $VERBOSE > 2; } - + ($CMD, $PH) = (join(" ", @{$self->{"CMD"}}), $self->{"PH"}); CORE::close $PH or die "$THIS_FILE: $CMD: $!"; CORE::close $FH or die "$THIS_FILE: $file: $!"; @@ -1967,7 +1965,7 @@ sub close : method { delete $self->{"CMD"}; delete $self->{"FH"}; delete $self->{"file"}; - + # Delete the file if ($keep eq KEEP_DELETE) { print STDERR " Deleting file ... " if $VERBOSE > 2; @@ -1995,10 +1993,10 @@ import main; use Fcntl qw(:flock :seek); use File::Temp qw(tempfile); -# suffix: The file name suffix of this mime type +# The file name suffix of this mime type sub suffix : method { ".bz2"; } -# open_read: Open the file for reading +# Open the file for reading sub open_read : method { local ($_, %_); my ($self, $file, $FH); @@ -2019,7 +2017,7 @@ sub open_read : method { return; } -# open_write: Open the file for writing +# Open the file for writing sub open_write : method { local ($_, %_); my ($self, $file, $FH); @@ -2040,7 +2038,7 @@ sub open_write : method { return; } -# open_append: Open the file for appending +# Open the file for appending sub open_append : method { local ($_, %_); my ($self, $file, $FH, $bz); @@ -2055,7 +2053,7 @@ sub open_append : method { } ($self->{"file"}, $self->{"FH"}) = ($file, $FH); import Compress::Bzip2 qw(bzopen); - + # Save the original data if file has content so that file size is # greater than 0. STDOUT is always of size 0. if ((stat $FH)[7] > 0) { @@ -2073,7 +2071,7 @@ sub open_append : method { seek $FH, 0, SEEK_SET or die "$THIS_FILE: $file: $!"; truncate $FH, 0 or die "$THIS_FILE: $file: $!"; print STDERR "done\n" if $VERBOSE > 2; - + # Decompress the buffer and save to our file print STDERR " Attaching buffer with bzopen(..., \"rb\") ... " if $VERBOSE > 2; $bzt = bzopen($FHT, "rb") or die "$THIS_FILE: tempfile: $!"; @@ -2081,7 +2079,7 @@ sub open_append : method { print STDERR " Attaching file with bzopen(..., \"wb9\") ... " if $VERBOSE > 2; $bz = bzopen($FH, "wb9") or die "$THIS_FILE: $file: $!"; print STDERR "done\n" if $VERBOSE > 2; - + print STDERR " Reading old records back from the buffer ... " if $VERBOSE > 2; $count = 0; while (($n = $bzt->bzreadline($_)) != 0) { @@ -2092,19 +2090,19 @@ sub open_append : method { } close $FHT or die "$THIS_FILE: tempfile: $!"; print STDERR "$count records\n" if $VERBOSE > 2; - + # A whole new file } else { print STDERR " Attaching file with bzopen(..., \"wb9\") ... " if $VERBOSE > 2; $bz = bzopen($FH, "wb9") or die "$THIS_FILE: $file: $!"; print STDERR "done\n" if $VERBOSE > 2; } - + $self->{"bz"} = $bz; return; } -# readline: Read a line from the I/O stream +# Read a line from the I/O stream sub readline : method { local ($_, %_); my ($self, $file, $bz, $n); @@ -2115,7 +2113,7 @@ sub readline : method { return $_; } -# write: Output data to the I/O stream +# Output data to the I/O stream sub write : method { local ($_, %_); my ($self, $file, $bz); @@ -2126,22 +2124,22 @@ sub write : method { return; } -# close: Close the I/O stream +# Close the I/O stream sub close : method { local ($_, %_); my ($self, $keep, $tmp, $file, $FH, $bz); ($self, $keep, $tmp) = @_; $keep = KEEP_ALL if @_ < 2; ($file, $FH, $bz) = ($self->{"file"}, $self->{"FH"}, $self->{"bz"}); - + # Restart the file - if ($keep eq KEEP_RESTART || $keep eq KEEP_THISMONTH) { + if ($keep eq KEEP_RESTART || $keep eq KEEP_THIS_MONTH) { # Empty the source file print STDERR " Emptying file ... " if $VERBOSE > 2; seek $FH, 0, SEEK_SET or die "$THIS_FILE: $file: $!"; truncate $FH, 0 or die "$THIS_FILE: $file: $!"; print STDERR "done\n" if $VERBOSE > 2; - + # Create empty compressed content print STDERR " Applying empty compressed content ... " if $VERBOSE > 2; $_ = bzopen($FH, "wb9") or die "$THIS_FILE: $file: $!"; @@ -2150,7 +2148,7 @@ sub close : method { undef $bz; print STDERR "done\n" if $VERBOSE > 2; } - + if (defined $bz) { $bz->bzclose and die "$THIS_FILE: $file: " . $bz->bzerror; } @@ -2158,7 +2156,7 @@ sub close : method { delete $self->{"bz"}; delete $self->{"FH"}; delete $self->{"file"}; - + # Delete the file if ($keep eq KEEP_DELETE) { print STDERR " Deleting file ... " if $VERBOSE > 2; @@ -2186,15 +2184,15 @@ import main; use Fcntl qw(:flock :seek); use File::Temp qw(tempfile); -use vars qw($EXEC); +our ($EXEC); BEGIN { undef $EXEC; } -# suffix: The file name suffix of this mime type +# The file name suffix of this mime type sub suffix : method { ".bz2"; } -# open_read: Open the file for reading +# Open the file for reading sub open_read : method { local ($_, %_); my ($self, $file, $FH, $PH, $CMD); @@ -2209,8 +2207,8 @@ sub open_read : method { flock $FH, LOCK_UN; } ($self->{"file"}, $self->{"FH"}) = ($file, $FH); - $EXEC = whereis "bzip2" if !defined $EXEC; - + $EXEC = where_is "bzip2" if !defined $EXEC; + @_ = ($EXEC, "-cdf"); @_ = map "\"$_\"", @_ if $^O eq "MSWin32"; $CMD = join " ", @_; @@ -2230,7 +2228,7 @@ sub open_read : method { return; } -# open_write: Open the file for writing +# Open the file for writing sub open_write : method { local ($_, %_); my ($self, $file, $FH, $PH, $CMD); @@ -2245,8 +2243,8 @@ sub open_write : method { flock $FH, LOCK_UN; } ($self->{"file"}, $self->{"FH"}) = ($file, $FH); - $EXEC = whereis "bzip2" if !defined $EXEC; - + $EXEC = where_is "bzip2" if !defined $EXEC; + @_ = ($EXEC, "-9f"); @_ = map "\"$_\"", @_ if $^O eq "MSWin32"; $CMD = join " ", @_; @@ -2266,7 +2264,7 @@ sub open_write : method { return; } -# open_append: Open the file for appending +# Open the file for appending sub open_append : method { local ($_, %_); my ($self, $file, $FH, $PH, $CMD); @@ -2281,12 +2279,12 @@ sub open_append : method { flock $FH, LOCK_UN; } ($self->{"file"}, $self->{"FH"}) = ($file, $FH); - $EXEC = whereis "bzip2" if !defined $EXEC; - + $EXEC = where_is "bzip2" if !defined $EXEC; + # Save the original data if file has content so that file size is # greater than 0. STDOUT is always of size 0. if ((stat $FH)[7] > 0) { - my ($count, $FHT, $PHT, $CMDT); + my ($count, $FHT, $PHT, $CMD_T); seek $FH, 0, SEEK_SET or die "$THIS_FILE: $file: $!"; # Copy the original content to a buffer print STDERR " Reading compressed data to the buffer ... " if $VERBOSE > 2; @@ -2300,24 +2298,24 @@ sub open_append : method { seek $FH, 0, SEEK_SET or die "$THIS_FILE: $file: $!"; truncate $FH, 0 or die "$THIS_FILE: $file: $!"; print STDERR "done\n" if $VERBOSE > 2; - + # Decompress the buffer and save to our file @_ = ($EXEC, "-cdf"); @_ = map "\"$_\"", @_ if $^O eq "MSWin32"; - $CMDT = join " ", @_; - print STDERR " Starting $CMDT from buffer ... " if $VERBOSE > 2; + $CMD_T = join " ", @_; + print STDERR " Starting $CMD_T from buffer ... " if $VERBOSE > 2; # Redirect STDIN to $FH open STDIN, "<&", $FHT or die "$THIS_FILE: tempfile: $!"; # Start the process if ($^O eq "MSWin32") { - open $PHT, "$CMDT |" or die "$THIS_FILE: $CMDT: $!"; + open $PHT, "$CMD_T |" or die "$THIS_FILE: $CMD_T: $!"; } else { - open $PHT, "-|", @_ or die "$THIS_FILE: $CMDT: $!"; + open $PHT, "-|", @_ or die "$THIS_FILE: $CMD_T: $!"; } # Restore STDIN open STDIN, "<&", $STDIN or die "$THIS_FILE: STDIN: $!"; print STDERR "done\n" if $VERBOSE > 2; - + @_ = ($EXEC, "-9f"); @_ = map "\"$_\"", @_ if $^O eq "MSWin32"; $CMD = join " ", @_; @@ -2333,17 +2331,17 @@ sub open_append : method { # Restore STDOUT open STDOUT, ">&", $STDOUT or die "$THIS_FILE: STDOUT: $!"; print STDERR "done\n" if $VERBOSE > 2; - + print STDERR " Reading old records back from the buffer ... " if $VERBOSE > 2; $count = 0; while (defined($_ = <$PHT>)) { print $PH $_ or die "$THIS_FILE: $file: $!"; $count++; } - close $PHT or die "$THIS_FILE: $CMDT: $!"; + close $PHT or die "$THIS_FILE: $CMD_T: $!"; close $FHT or die "$THIS_FILE: tempfile: $!"; print STDERR "$count records\n" if $VERBOSE > 2; - + # A whole new file } else { @_ = ($EXEC, "-9f"); @@ -2362,12 +2360,12 @@ sub open_append : method { open STDOUT, ">&", $STDOUT or die "$THIS_FILE: STDOUT: $!"; print STDERR "done\n" if $VERBOSE > 2; } - + ($self->{"CMD"}, $self->{"PH"}) = ([@_], $PH); return; } -# readline: Read a line from the I/O stream +# Read a line from the I/O stream sub readline : method { local ($_, %_); my ($self, $PH); @@ -2376,7 +2374,7 @@ sub readline : method { return <$PH>; } -# write: Output data to the I/O stream +# Output data to the I/O stream sub write : method { local ($_, %_); my ($self, $CMD, $PH); @@ -2386,26 +2384,26 @@ sub write : method { return; } -# close: Close the I/O stream +# Close the I/O stream sub close : method { local ($_, %_); my ($self, $keep, $tmp, $file, $FH, $CMD, $PH); ($self, $keep, $tmp) = @_; $keep = KEEP_ALL if @_ < 2; ($file, $FH) = ($self->{"file"}, $self->{"FH"}); - + # Restart the file - if ($keep eq KEEP_RESTART || $keep eq KEEP_THISMONTH) { + if ($keep eq KEEP_RESTART || $keep eq KEEP_THIS_MONTH) { my ($CMD, $PH); # Empty the source file print STDERR " Emptying file ... " if $VERBOSE > 2; seek $FH, 0, SEEK_SET or die "$THIS_FILE: $file: $!"; truncate $FH, 0 or die "$THIS_FILE: $file: $!"; print STDERR "done\n" if $VERBOSE > 2; - + # Create empty compressed content print STDERR " Applying empty compressed content ... " if $VERBOSE > 2; - $EXEC = whereis "bzip2" if !defined $EXEC; + $EXEC = where_is "bzip2" if !defined $EXEC; @_ = ($EXEC, "-9f"); @_ = map "\"$_\"", @_ if $^O eq "MSWin32"; $CMD = join " ", @_; @@ -2422,7 +2420,7 @@ sub close : method { open STDOUT, ">&", $STDOUT or die "$THIS_FILE: STDOUT: $!"; print STDERR "done\n" if $VERBOSE > 2; } - + ($CMD, $PH) = (join(" ", @{$self->{"CMD"}}), $self->{"PH"}); CORE::close $PH or die "$THIS_FILE: $CMD: $!"; CORE::close $FH or die "$THIS_FILE: $file: $!"; @@ -2430,7 +2428,7 @@ sub close : method { delete $self->{"CMD"}; delete $self->{"FH"}; delete $self->{"file"}; - + # Delete the file if ($keep eq KEEP_DELETE) { print STDERR " Deleting file ... " if $VERBOSE > 2; @@ -2455,19 +2453,19 @@ import main; use Date::Parse qw(str2time); -# new: Initialize the log record format parser +# Initialize the log record format parser sub new : method { bless {}, $_[0]; } -# check_format: Check the record format and return an appropriate parser +# Check the record format and return an appropriate parser sub check_format : method { local ($_, %_); - my (@fmts, $record); + my (@formats, $record); $record = $_[1]; - @fmts = qw(_private::Format::Apache _private::Format::Syslog + @formats = qw(_private::Format::Apache _private::Format::Syslog _private::Format::NTP _private::Format::ApacheSSL - _private::Format::ModfISO); - foreach my $fmt (@fmts) { - $_ = $fmt->new; + _private::Format::MyISO); + foreach my $format (@formats) { + $_ = $format->new; print STDERR " Testing $_ ... " if $VERBOSE > 2; if ($_->match($record)) { print STDERR "match\n" if $VERBOSE > 2; @@ -2478,11 +2476,11 @@ sub check_format : method { return undef; } -# match: Try matching my format and return the matching date text +# Try matching my format and return the matching date text # Empty. Implement it in the subclasses. sub match : method { return undef; } -# parse_month: Parse the month of the log file +# Parse the month of the log file sub parse_month : method { local ($_, %_); my $self; @@ -2499,9 +2497,9 @@ use 5.008; use strict; use warnings; use base qw(_private::Format); -use overload ("\"\"" => sub { "Apache acess_log"; }); +use overload ("\"\"" => sub { "Apache access_log"; }); -# match: Try matching my format and return the matching date text +# Try matching my format and return the matching date text sub match : method { return $_[1] =~ /^\S+ \S+ .*? \[(\d{2}\/[A-Z][a-z]{2}\/\d{4}:\d{2}:\d{2}:\d{2} [+\-]\d{4})\]/? $1: undef; @@ -2516,7 +2514,7 @@ use warnings; use base qw(_private::Format); use overload ("\"\"" => sub { "Syslog"; }); -# match: Try matching my format and return the matching date text +# Try matching my format and return the matching date text sub match : method { return $_[1] =~ /^([A-Z][a-z]{2} ?\d{1,2} \d{2}:\d{2}:\d{2}) /? $1: undef; @@ -2531,7 +2529,7 @@ use warnings; use base qw(_private::Format); use overload ("\"\"" => sub { "NTP"; }); -# match: Try matching my format and return the matching date text +# Try matching my format and return the matching date text sub match : method { return $_[1] =~ /^( ?\d{1,2} [A-Z][a-z]{2} \d{2}:\d{2}:\d{2}) /? $1: undef; @@ -2546,24 +2544,24 @@ use warnings; use base qw(_private::Format); use overload ("\"\"" => sub { "Apache SSL engine log"; }); -# match: Try matching my format and return the matching date text +# Try matching my format and return the matching date text sub match : method { return $_[1] =~ /^\[(\d{2}\/[A-Z][a-z]{2}\/\d{4} \d{2}:\d{2}:\d{2} )\d+\]/? $1: undef; } -# _private::Format::ModfISO: The bracketed, modified ISO 8601 date/time log file format handler +# _private::Format::MyISO: The bracketed, modified ISO 8601 date/time log file format handler # ISO 8601 should be 2007-11-14T14:23:35+0800. But it is hard to read. # This is a similar format commonly-seen in many applications. -package _private::Format::ModfISO; +package _private::Format::MyISO; use 5.008; use strict; use warnings; use base qw(_private::Format); use overload ("\"\"" => sub { "modified ISO 8601 date/time"; }); -# match: Try matching my format and return the matching date text +# Try matching my format and return the matching date text sub match : method { return $_[1] =~ /^\[(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} [+\-]\d{4})\]/? $1: undef; @@ -2588,13 +2586,13 @@ that belongs to previous months, and then compresses and saves them to archived files named logfile.yyyymm.gz. Currently, F supports Apache access log, Syslog, NTP, Apache -1 SSL engine log and my own bracketed, modified ISO date/time log +1 SSL engine log, and my own bracketed, modified ISO date/time log file formats, and gzip and bzip2 compression methods. Several software projects log (or can log) in a format compatible with the Apache access log, like CUPS, ProFTPD, Pure-FTPd... etc., and F can archive their Apache-like log files, too. -Notice: I. To reduce the time occupying the +Notice: I. To reduce the time occupying the source log file, F copies the content of the source log file to a temporary working file and restart the source log file first. Then F can take its time working on the temporary @@ -2603,44 +2601,41 @@ working file. However, please note: 1. If you have a huge log file (several hundreds of MBs), merely copying still takes a lot of time. In that case, you had better stop logging first, archive the log file and restart logging, to avoid -racing condition in writing. If you archive the log file periodly, -it shall not grow too big. +racing condition in writing. If you archive the log file +periodically, it shall not grow too big. 2. If F stops in the middle of the execution, it will leave -a temporary working file. The next time F runs, it will stop +a temporary working file. The next time F runs, it stops when it sees that temporary working file. You have to process that temporary working file first. That temporary working file is merely a copy of the original log file. You can rename and archive it like an ordinary log file to solve this. Do not sort unless you have a particular reason. Sorting has the -following potential problem: +following potential problems: 1. Sorting may I on large log files. The amount of the memory required depends on the number of records in each archived -month. Modern Linux and MSWin32 have memory consuming protection by -killing processes that eats too much memory, but it still takes -minutes, and your system will hang during that time. I do not know -the memory consuming protection on other operating systems. If you -try, you are at your own risk. +month. Modern Linux and MSWin32 kill processes that eat too much +memory, but it still takes minutes, and your system hangs for that. I +do not know other operating systems. Try at your own risk. -2. The time units of all recognized log formats are I. -Log records happen in a same second will be sorted by the log file -order (if you are archiving several log files at a time) and then -the log record order. I try to ensure that the sorted archived -records are in a correct order of the happening events, but I cannot -guarantee. You have to watch out if the order in a second is -important. +2. The time unit of all recognized log formats is I. Log +records happen in a same second are sorted by the log file order (if +you are archiving several log files at a time) and then the log record +order. I try to ensure that the sorted archived records are in a +correct order of the happening events, but I cannot guarantee. You +have to watch out if the order in a second is important. Be careful on the L and NTP log files: L and NTP does not record the year. F uses L to parse the date, which assumes the year between this month and last next month if the year is -missing. For ex., if today is 2001-06-08, it will then assume the -year between 2001-06-30 back to 2000-07-01 if the year is missing. I -think this is smart enough. However, if you do have a -L or NTP log file that has records older than one -year, do not use F. It will destroy your log file. +missing. For example, if today is 2001/6/8, it assumes the year +between 2001/6/30 back to 2000/7/1 if the year is missing. This is +fair. However, if you do have a L or NTP log file +that has records older than one year, do not use F. It will +destroy your log file. If read from C, please note: @@ -2649,25 +2644,23 @@ C, since what it needs is an output pathname prefix, not an output file. 2. C cannot be deleted, restarted or partially kept. If you -read from C, the keep mode will fall back to keep all. if -you archive several source log files including C, the keep -mode will fall back to keep all for all source log files, to prevent -disaster. +read from C, the keep mode is always keep all. if you archive +several source log files including C, the keep mode will be +keep all for all source log files, to prevent disaster. 3. The answers of the C mode is obtained from C, too. Since you have only one C, you cannot specify the C mode -while reading from C. It will fall back to the C mode +while reading from C. It falls back to the C mode in that case. -I suggest you to install L instead of -counting on the file executable. The internal magic file of -L seems to work better than the +I suggest that you install L instead +of counting on the L executable. The internal magic +file of L works better than the L executable. F treats everything not L nor L compressed as plain text. When a compressed log file is wrongly recognized as an image, -F will treat it as plain text, read log records directly from -it and fail. This failure does not hurt the source log files, but is -still annoying. +F treats it as plain text, reads directly from it, and fails. + This does not hurt the source log files, but is still annoying. =head1 OPTIONS @@ -2676,47 +2669,45 @@ still annoying. =item logfile The log file to be archived. Specify C<-> to read from C. -Multiple log files are supported. L or -L compressed files are supported, too. +You can specify multiple log files. L or +L compressed files are supported. =item output -The prefix of the output files. The output files will be named as +The prefix of the output files. The output files are named as F, ie: F, F. If not specified, the default is the same as the log file. You must specify this if you want to read from C. You cannot specify C<-> -(C), since this is only a name prefix, not the output file. +(C), since F needs a name prefix, not the output file. -=item -c,--compress method +=item -c, --compress method Specify the compression method for the archived files. Log files -usually have large number of simular lines. Compress them saves +usually have large number of similar lines. Compress them saves you lots of disk spaces. (And this is why we want to I -them.) Currently the following compression methods are supported: +them.) The following compression methods are supported: =over -=item g,gzip +=item g, gzip Compress with L. This is the default. F can use L to compress instead of calling L. This can be safer and faster for not -calling foreign binaries. But if -L is not installed, it will try -to use L instead. If L is not -available, either, the program will fail. +calling foreign binaries. if L +is not installed, it tries L instead. If +L is not available, either, it fails. -=item b,bzip2 +=item b, bzip2 Compress with L. F can use L to compress instead of calling L. This can be safer and faster for not -calling foreign binaries. But if -L is not installed, it will try -to use L instead. If L is not -available, either, the program will fail. +calling foreign binaries. If L +is not installed, it will try to use L instead. If +L is not available, either, it fails. -=item n,none +=item n, none No compression at all. (Why? :p) @@ -2724,52 +2715,53 @@ No compression at all. (Why? :p) =item --nocompress -Do not compress the archived files. This is equal to +Do not compress the archived files. This is equivalent to C<--compress none>. -=item -s,--sort +=item -s, --sort Sort the records by time (and then the record order). Sorting eats -huge memory and CPU, so it is disabled by default. See the +huge memory and CPU, so it is disabled by default. Refer to the description above for a detailed illustration on sorting. =item --nosort Do not sort the records. This is the default. -=item -o,--override mode +=item -o, --override mode -Whether we should overwrite the existing archived files. Currently -the following modes are supported: +What to do with the existing archived files. The following modes are +supported: =over -=item o,overwrite +=item o, overwrite -Overwrite existing target files. You will lost these existing +Overwrite existing target files. You will lose these existing records. Use with care. This is helpful if you are sure the master log file has the most complete records. -=item a,append +=item a, append Append the records to the existing target files. You may destroy the log file completely by putting irrelevant entries altogether -accidently. Use with care. This is helpful if you append want to -merge 2 or more log files, for ex., 2 log files of different periods. +by accident. Use with care. This is helpful if you append want to +merge 2 or more log files, for example, 2 log files of different +periods. -=item i,ignore +=item i, ignore Ignore any existing target file, and discard all the records of those -months. You will lost these log records. Use with care. This is +months. You will lose these log records. Use with care. This is helpful if you are supplying log records for the missing months, or if you are merging the log records in a complex manner. -=item f,fail +=item f, fail -Stop processing whenever a target file exists, to prevent destroying -existing files by accident. This should be mostly wanted when run -from some automatic mechanism, like L. So, -this is the default if no terminal is found at C. +Stop whenever a target file exists, to prevent destroying existing +files by accident. This should be mostly desired when run from some +automatic mechanism, like L. So, this is the +default if no terminal is found at C. =item ask @@ -2778,33 +2770,31 @@ wanted if you are running F interactively. So, this is the default if a terminal is found at C. The answers are read from C. Since you have only one C, you cannot specify this mode if you want read the log file from C. In that case, -it will fall back to the fail mode. Also, if -F cannot get its answer from C, for ex., on a -closed C like L, it will fall back to -C mode. +it falls back to the C mode. Also, if F cannot get its +answer from C, for example, on a closed C from +L, it falls back to C mode. =back -=item -k,--keep mode +=item -k, --keep mode -What to keep in the source file. Currently the following modes are -supported: +What to keep in the source file. The following modes are supported: =over -=item a,all +=item a, all Keep the source file after records are archived. -=item r,restart +=item r, restart Restart the source file after records are archived. -=item d,delete +=item d, delete Delete the source file after records are archived. -=item t,this-month +=item t, this-month Archive and strip records of previous months off from the log file. Keep the records of this month in the source log file, to be archived @@ -2819,7 +2809,7 @@ Show the detailed debugging messages. =item -q, --quiet -Shihhhhhh. Only yell when errors. +Hush! Only yell on error. =item -h, --help @@ -2833,36 +2823,28 @@ Output version information and exit. =head1 COPYRIGHT -Copyright (c) 2001-2007 imacat. All rights reserved. +Copyright (c) 2001-2021 imacat. -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at -This program is distributed in the hope that it will be useful, -but I; without even the implied warranty of -I or I. See the -GNU General Public License for more details. + http://www.apache.org/licenses/LICENSE-2.0 -You should have received a copy of the GNU General Public License -along with this program. If not, see L. +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. =head1 AUTHOR -imacat . Please visit F's -websites at http://arclog.sourceforge.net/ and -http://www.imacat.idv.tw/tech/arclog.html . +imacat . =head1 BUGS -F has a mailing list at SourceForge: -arclog-users@lists.sourceforge.net. It is for -F's users to discuss and report problems. Its web page is -at http://lists.sourceforge.net/lists/listinfo/arclog-users . -If you have any problem or question on F, please go to -this page, join the list, and send your questions on this list. -Thank you. +The F project is hosted on GitHub. Address your issues on the +GitHub issue tracker https://github.com/imacat/arclog/issues. =head1 TODO @@ -2870,8 +2852,8 @@ Thank you. =item Multi-lingual support -Support multi-lingual, either with L or -perl 5.8.0's L. +Multi-lingual support, with Traditional and Simplified Chinese +messages. =back diff --git a/arclog.en.html b/arclog.en.html deleted file mode 100644 index 093cdab..0000000 --- a/arclog.en.html +++ /dev/null @@ -1,506 +0,0 @@ - - - - - - - - - - - - - - - -arclog Version 3.04 - - - -
- 正體中文 | - 简体中文 | - English -
-
- - -
- - -

arclog Version 3.04

- - -

What’s New?

- -
-
2007-12-03
- -
-

arclog version 3.04 is released. Documentation fixes. Upgrade is not necessary if you have installed arclog version 3.00 or later. Download arclog version 3.04.

-
- - -
2007-12-03
- -
-

arclog version 3.03 is released. Test suite fixes. Required Perl version number compatible to older versions, to work with the Perl 5.10 warning. Upgrade is not necessary if you have installed arclog version 3.00 or later. Download arclog version 3.03.

-
- - -
2007-11-30
- -
-

arclog version 3.02 is released. Test suite improvement, in order to deal with daylight saving time. Upgrade is not necessary if you have installed arclog version 3.00 or later. Download arclog version 3.02.

-
- - -
2007-11-28
- -
-

arclog version 3.01 is released. Test suite improvement, in order to catch CPAN tester failures. Upgrade is not necessary if you have installed arclog version 3.00. Download arclog version 3.01.

-
- - -
2007-11-28
- -
-

arclog version 3.00 is released. The code is completely new borrowed from reslog, with the name changed from arclog.pl to arclog, too. The new object-oriented handlers deal with different compression methods, formats nicely. Perl’s s build system ExtUtils::MakeMaker and Module::Build are used instead of GNU autoconf. And there is a complete test suite that help quality assurance. License updated to GPLv3. Download arclog version 3.00.

-
- - -
2002-09-26
- -
-

arclog.pl version 2.1.0 is released. This is the final 2.1.0 release. It adds support for bzip2 compression, gzip compression with gzip binary instead of Compress::Zlib, and GNU autoconf configuration script. Download arclog.pl version 2.1.0.

-
- - -
2002-09-18
- -
-

arclog.pl version 2.1.0dev2 is released. This release corrects several documentation errors. It also adds SourceForge in the documentations as one of the sources of arclog.pl. You can think of it as a Source Forge Memorial Release. :p You do nott have to upgrade to this version in a rush. Download arclog.pl version 2.1.0dev2.

-
- - -
2002-09-17
- -
-

arclog.pl is hosted at SourceForge now! Congratulations! (Although I’m still trying hard to get it working at this time… ^^; )

-
-
- - -

Description

- -

arclog archives the log files monthly. It strips off previous months’ log records from the log file, and save them to compressed archive files named logfile.yyyymm. It then saves the hard disk space and prevents potential attacks on log files.

- -

Currently, arclog supports Apache access log, Syslog, NTP, Apache 1 SSL engine log and my own bracketed, modified ISO date/time log file formats, and gzip and bzip2 compression methods. Several software projects log (or can log) in a format compatible with the Apache access log, like CUPS, ProFTPD, Pure-FTPdetc., and arclog can archive their Apache-like log files, too.

- - -

Caution

- -
    -
  • Archiving takes time. To reduce the time occupying the source log file, arclog copies the content of the source log file to a temporary working file and restart the source log file first. Then arclog can take its time working on the temporary working file. However, please note:

    -
      -
    1. If you have a huge log file (several hundreds of MBs), merely copying still takes a lot of time. You had better stop logging first, archive the log file and restart logging, to avoid racing condition in writing. If you archive the log file periodly, it shall not grow too big.

    2. -
    3. Ifarclog stops in the middle of the execution, it will leave a temporary working file. The next time arclog runs, it will stop when it sees that temporary working file. You have to process that temporary working file first. That temporary working file is merely a copy of the original log file. You can rename and archive it like an ordinary log file to solve this.

    4. -
    -
  • - -
  • Do not sort unless you have a particular reason. Sorting has the following potential problem:

    -
      -
    1. Sorting may eat huge memory on large log files. The amount of the memory required depends on the number of records in each archived month. Modern Linux and MS-Windows have memory consuming protection by killing processes that eats too much memory, but it still takes minutes, and your system will hang during that time. I do not know the memory consuming protection on other operating systems. If you try, you are at your own risk.

    2. -
    3. The time units of all recognized log formats are second. Log records happen in a same second will be sorted by the log file order (if you are archiving several log files at a time) and then the log record order. I try to ensure that the sorted archived records are in a correct order of the happening events, but I cannot guarantee. You have to watch out if the order in a second is important.

    4. -
    -
  • - -
  • Be careful on the Syslog and NTP log files: Syslog and NTP does not record the year. arclog uses Date::Parse to parse the date, which assums the year between this month and last next month if the year is missing. For ex., if today is 2001-06-08, it will then assume the year between 2001-06-30 back to 2000-07-01. I think this is smart enough. However, if you do have a Syslog or NTP log file that has records older than one year, do not use arclog. It will destroy your log file.

  • - -
  • If read from STDIN, please note:

    -
      -
    1. You must specify the output prefix if you want to read from STDIN, since what it needs is an output pathname prefix, not an output file.

    2. -
    3. STDIN cannot be deleted, restarted or partially kept. If you read from STDIN, the keep mode will fall back to keep all. If you archive several source log files including STDIN, the keep mode will fall back to keep all for all source log files, to prevent disaster.

    4. -
    5. The answers of the ask mode is obtained from STDIN, too. Since you have only one STDIN, you cannot specify the ask mode while reading from STDIN. It will fall back to the fail mode in that case.

    6. -
    -
  • - -
  • I suggest you to install File::MMagic instead of counting on the file executable. The internal magic file of File::MMagic seems to work better than the file executable. arclog treats everything not gzip nor bzip2 compressed as plain text. When a compressed log file is wrongly recognized as an image, arclog will treat it as plain text, read log records directly from it and fail. This failure does not hurt the source log files, but is still annoying.

  • -
- - -

System Requirement

- -
    -
  1. Perl, version 5.8.0 or above. arclog uses 3-argument open() to duplicate filehandles, which is only supported since 5.8.0. I have not successfully port this onto earlier versions yet. Please tell me if you made it. You can run perl -v to see your current Perl version. If you do not have Perl, or if you have an older version of Perl, you can download and install/upgrade it from Perl website. If you are using MS-Windows, you can download and install ActiveState ActivePerl.

  2. - -
  3. Required Perl modules:

    - -
    -
    Date::Parse
    - -
    -

    This is used to parse the timestamp of the log records. You can download and install Date::Parse from the CPAN archive, or install it with the CPAN shell by running cpan Date::Parse, or install it with the CPANPLUS shell by running cpanp i Date::Parse. Debian/Ubandu Linux users can install it by running apt-get install libtimedate-perl. Red Hat/Fedora/CentOS Linux users can install it by running yum install perl-TimeDate. FreeBSD users can install it by running ports install p5-TimeDate. ActivePerl users can install it by running ppm install Date::Parse.

    -
    -
    - -

    If you install arclog with the CPAN or CPAN shell, the above shall be automatically installed.

    -
  4. - -
  5. Optional Perl modules:

    - -
    -
    File::MMagic
    - -
    -

    This is used to check the file type. If this is not available, arclog will look for the file executable instead. If that is not available, too, arclog will judge the file type by its name suffix (extension). In that case arclog will fail when reading from STDIN. You can download and install File::MMagic from the CPAN archive, or install it with the CPAN shell by running cpan File::MMagic, or install it with the CPANPLUS shell by running cpanp i Term::ReadKey. Debian/Ubandu Linux users can install it by running apt-get install libfile-mmagic-perl. Red Hat/Fedora/CentOS Linux users can install it by running yum install perl-File-MMagic. FreeBSD users can install it by running ports install p5-File-MMagic. ActivePerl users can install it by running ppm install File::MMagic. The alternative file.exe for MS-Windows can be obtained from the GnuWin32 home page. Be sure to save it as file.exe somewhere in your PATH.

    - -

    It is preferred to use File::MMagic. The file executable seems to make mistakes occationally.

    -
    - -
    Compress::Zlib
    - -
    -

    This is used to support read/write of gzip compressed files. It is only needed when gzip compressed files are encountered. If it is not available when needed, arclog will try to use the gzip executable instead. If that is not available, too, arclog will fail. You can download and install Compress::Zlib from the CPAN archive, or install it with the CPAN shell by running cpan Compress::Zlib, or install it with the CPANPLUS shell by running cpanp i Compress::Zlib. Debian/Ubandu Linux users can install it by running apt-get install libcompress-zlib-perl. Red Hat/Fedora/CentOS Linux users can install it by running yum install perl-Compress-Zlib. FreeBSD users can install it by running ports install p5-Compress-Zlib. ActivePerl users can install it by running ppm install Compress::Zlib. The alternative gzip.exe for MS-Windows can be obtained from the gzip home page. Be sure to save it as gzip.exe somewhere in your PATH.

    -
    - -
    Compress::Bzip2, version 2 or above
    - -
    -

    This is used to support read/write of bzip2 compressed files. It is only needed when bzip2 compressed files are encountered. If it is not available when needed, arclog will try to use the bzip2 executable instead. If that is not available, too, arclog will fail. Notice that older versions before 2 does not work, since file I/O compression were not implemented yet. You can download and install Compress::Bzip2 from the CPAN archive, or install it with the CPAN shell by running cpan Compress::Bzip2, or install it with the CPANPLUS shell by running cpanp i Compress::Bzip2. Debian/Ubandu Linux users can install it by running apt-get install libcompress-bzip2-perl. Red Hat/Fedora/CentOS Linux users can install it by running yum install perl-Compress-Bzip2. FreeBSD users can install it by running ports install p5-Compress-Bzip2. ActivePerl users can install it by running ppm install Compress::Bzip2. The alternative bzip2.exe for MS-Windows can be obtained from the bzip2 home page. Be sure to save it as bzip2.exe somewhere in your PATH.

    -
    - -
    Term::ReadKey
    - -
    -

    This is used to display the progress bar. Without this arclog will not display the progress bar, but nothing else is different. The progress bar is a good visual representation of what arclog is currently doing. You can download and install Term::ReadKey from the CPAN archive, or install it with the CPAN shell by running cpan Term::ReadKey, or install it with the CPANPLUS shell by running cpanp i Term::ReadKey. Debian/Ubandu Linux users can install it by running apt-get install libterm-readkey-perl. Red Hat/Fedora/CentOS Linux users can install it by running yum install perl-TermReadKey. FreeBSD users can install it by running ports install p5-Term-ReadKey. ActivePerl users can install it by running ppm install Term::ReadKey.

    -
    -
    -
  6. -
- - -

Download

- -

arclog’s official websites is at…

- - - -

You can always download the newest version of arclog from…

- - - -

imacat’s PGP public key is at…

- - - - -

Install

- -

If you are upgrading from arclog.pl 2.1.1dev4 or earlier, please read UPGRADE for some upgrade instruction.

- -

Install with ExtUtils::MakeMaker

- -

arclog uses standard Perl installation with ExtUtils::MakeMaker. Follow these steps:

- -
-% perl Makefile.PL
-% make
-% make test
-% make install
-
- -

When running make install, make sure you have the priviledge to write to the installation location. This usually requires the root priviledge.

- -

If you are using ActivePerl under MS-Windows, you should use nmake instead of make. nmake can be obtained from the Microsoft FTP site.

- -

If you want to install into another location, you can set the PREFIX. For example, to install into your home when you are not root:

- -
-% perl Makefile.PL PREFIX=/home/jessica
-
- -

Refer to the docuemntation of ExtUtils::MakeMaker for more installation options (by running perldoc ExtUtils::MakeMaker).

- - -

Install with Module::Build

- -

You can install with Module::Build instead, if you prefer. Follow these steps:

- -
-% perl Build.PL
-% ./Build
-% ./Build test
-% ./Build install
-
- -

When running ./Build install, make sure you have the priviledge to write to the installation location. This usually requires the root priviledge.

- -

If you want to install into another location, you can set the --prefix. For example, to install into your home when you are not root:

- -
-% perl Build.PL --prefix=/home/jessica
-
- -

Refer to the docuemntation of Module::Build for more installation options (by running perldoc Module::Build).

- - -

Options

- -
-./arclog [options] logfile… [output]
-./arclog [-h|-v]
-
- - -
-
logfile
- -
-

The log file to be archived. Specify - to read from STDIN. Multiple log files are supported. gzip or bzip2 compressed files are supported, too.

-
- - -
output
- -
-

The prefix of the output files. The output files will be named as output.yyyymm, i.e., output.200101, output.200102. If not specified, the default is the same as the log file. You must specify this if you want to read from STDIN. You cannot specify - (STDIN), since this is only a name prefix, not the output file.

-
- - -
-c, --compress method
- -
-

Specify the compression method for the archived files. Log files usually have large number of simular lines. Compress them saves you lots of disk spaces. (And this is why we want to archive them.) Currently the following compression methods are supported:

- - -
-
g, gzip
- -
-

Compress with gzip. This is the default. arclog can use Compress::Zlib to compress instead of calling gzip. This can be safer and faster for not calling foreign binaries. But if Compress::Zlib is not installed, it will try to use gzip binary instead. If gzip binary is not available, either, but gzip compression is required, the program will fail.

-
- - -
b, bzip2
- -
-

Compress with bzip2. arclog can use Compress::Bzip2 to compress instead of calling bzip2. This can be safer and faster for not calling foreign binaries. But if Compress::Bzip2 is not installed, it will try to use bzip2 binary instead. If bzip2 binary is not available, either, but bzip2 compression is required, the program will fail.

-
- - -
n, none
- -
-

No compression at all. (Why? :p)

-
-
-
- - -
--nocompress
- -
-

Do not compress the archived files. This is equal to --compress none.

-
- - -
-s, --sort
- -
-

Sort the records by time (and then the record order). Sorting eats huge memory and CPU, so it is disabled by default. See the description above for a detailed illustration on sorting.

-
- - -
--nosort
- -
-

Do not sort the records. This is the default.

-
- - -
-o, --override mode
- -
-

Whether we should overwrite the existing archived files. Currently the following modes are supported:

- - -
-
o, overwrite
- -
-

Overwrite existing target files. You will lost these existing records. Use with care. This is helpful if you are sure the master log file has the most complete records.

-
- - -
a, append
- -
-

Append the records to the existing target files. You may destroy the log file completely by putting irrelevant entries altogether accidently. Use with care. This is helpful if you append want to merge 2 or more log files, for ex., 2 log files of different periods.

-
- - -
i, ignore
- -
-

Ignore any existing target file, and discard all the records of those months. You will lost these log records. Use with care. This is helpful if you are supplying log records for the missing months, or if you are merging the log records in a complex manner.

-
- - -
f, fail
- -
-

Stop processing whenever a target file exists, to prevent destroying existing files by accident. This should be mostly wanted when run from some automatic mechanism, like crontab. So, this is the default if no terminal is found at STDIN.

-
- - -
ask
- -
-

Ask you what to do when a target file exists. This should be most wanted if you are running arclog interactively. So, this is the default if a terminal is found at STDIN. The answers are read from STDIN. Since you have only one STDIN, you cannot specify this mode if you want read the log file from STDIN. In that case, it will fall back to the fail mode. Also, if arclog cannot get its answer from STDIN, for ex., on a closed STDIN like crontab, it will fall back to fail mode.

-
-
-
- - -
-k, --keep mode
- -
-

What to keep in the source file. Current the following modes are supported:

- -
-
a, all
- -
-

Keep the source file after records are archived.

-
- - -
r, restart
- -
-

Restart the source log file after records are archived.

-
- - -
d, delete
- -
-

Delete the source log file after records are archived.

-
- - -
t, this-month
- -
-

Archive and strip records of previous months off from the log file. Keep the records of this month in the source log file, to be archived next month. This is designed to be run from crontab monthly, so this is the default.

-
-
-
- - -
-d, --debug
- -
-

Show the detailed debugging messages.

-
- - -
-q, --quiet
- -
-

Shihhhhhh. Only yell when errors.

-
- - -
-h, --help
- -
-

Display the help message and exit.

-
- - -
-v, --version
- -
-

Output version information and exit.

-
-
- - -

Copyright

- -

Copyright © 2001-2007 imacat..

- -

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

- -

This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

- -

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

- - -

Release Notes

- -

Please read the NEWS for the new functions and bug fixes.

- - -

Support

- -

arclog is hosted on SourceForge, CPAN and Tavern IMACAT’s. For the latest infomation, see

- - - -

There is a arclog mailing list hosted at SourceForge. Please submit your questions, suggestions or bug reports there. It is a Mailman mailing list. For more information, see the arclog mailing list page. Alternatively, you can send a mail to the e-mail command mailbox with the subject help for a list of available e-mail commands.

- -
- - -
- - - - diff --git a/arclog.zh-cn.html b/arclog.zh-cn.html deleted file mode 100644 index 7c130e9..0000000 --- a/arclog.zh-cn.html +++ /dev/null @@ -1,510 +0,0 @@ - - - - - - - - - - - - - - - -arclog 3.04 唳 - - - -
- 淏體笢恅 | - 潠极笢恅 | - English -
-
- - -
- - -

arclog 3.04 唳

- - -

郔陔秏洘

- -
-
2007-12-03
- -
-

arclog 郔陔唳掛 3.04 ﹝佽隴恅璃党淏﹝蠙蜣旁偽終偭 arclog 3.00 唳麼眳綴腔唳掛ㄛ祥剒猁汔撰陔唳﹝狟婥 arclog 3.04 唳

-
- - -
2007-12-03
- -
-

arclog 郔陔唳掛 3.03 ﹝党淏聆彸杶璃﹝垀剒 Perl 唳掛瘍鎢蜊蚚眈椷馮仱瘚贍鷓賳鯓膛皆婘壺 Perl 5.10 腔劑豢捅洘﹝蠙蜣旁偽終偭 arclog 3.00 唳麼眳綴腔唳掛ㄛ祥剒猁汔撰陔唳﹝狟婥 arclog 3.03 唳

-
- - -
2007-11-30
- -
-

arclog 郔陔唳掛 3.02 ﹝党淏聆彸杶璃ㄛ眕揭燴桯熀祲暱掉餂帎漶蠙蜣旁偽終偭 arclog 3.00 唳麼眳綴腔唳掛ㄛ祥剒猁汔撰陔唳﹝狟婥 arclog 3.02 唳

-
- - -
2007-11-28
- -
-

arclog 郔陔唳掛 3.01 ﹝党淏聆彸杶璃ㄛ眕衪翑濰ь CPAN 聆彸隙惆腔渣昫﹝蠙蜣旁偽終偭 arclog 3.00 唳ㄛ祥剒猁汔撰陔唳﹝狟婥 arclog 3.01 唳

-
- - -
2007-11-28
- -
-

arclog 郔陔唳掛 3.00 ﹝植 reslog 質徹懂腔峒糧昃蝓諴炸腕珩植 arclog.pl 蜊峈 arclog ﹝陔腔昜璃絳砃揭燴んㄛ褫佼瞳揭燴跪笱揤坫楊摯紫偶跡宒﹝假蚾炵苀蚕 GNU autoconf 蜊蚚 PerlExtUtils::MakeMakerModule::Build ﹝陔樓奻俇淕腔聆彸杶璃ㄛ衪翑最宒こ奪﹝唳邪陔峈 GPLv3狟婥 arclog 3.00 唳

-
- - -
2002-09-26
- -
-

arclog.pl 郔陔唳掛 2.1.0 ﹝涴岆 2.1.0 腔郔笝唳ㄛ樓奻賸 bzip2 揤坫腔盓堔ㄛ蚚 gzip 最宒測杸 Compress::Zlib 揤坫ㄛ甜蜊蚚 GNU autoconf 假蚾扢隅最宒﹝狟婥 arclog.pl 2.1.0

-
- - -
2002-09-18
- -
-

arclog.pl 郔陔唳掛 2.1.0dev2 ﹝掛唳党淏賸撓跺佽隴恅璃腔渣昫ㄛ甜參 SourceForge 樓輛 arclog.pl 腔狟婥厙硊笢﹝斕褫眕參坳絞酕扠③ SourceForge 槨癩唳﹝埻寀奻ㄛ祥剒猁摹翍汔撰﹝狟婥 arclog.pl 2.1.0dev2

-
- - -
2002-09-17
- -
-

疑秏洘ㄐ arclog.pl 眒羲宎殤扢黺 SourceForge 蹕ㄐㄗ呥銜瓞蛹齠嗶糔姜蓂鉸撜猁崋繫殤#類坰笢# ^^; ㄘ

-
-
- - - -

佽隴

- -

arclog 岆暮翹紫藩堎寥紫最宒ㄛ蔚暮翹紫笢ㄛヶ堎腔暮翹偌堎爺揤坫寥紫ㄛ眕誹吽茞詠諾潔ㄛ甜旌轎暮翹紫掩衄陑侕褪し窗

- -

arclog 醴ヶ盓堔 ApacheSyslogNTPApache 1 SSL engine log 摯扂赻撩蚚腔嬤說 ISO 党淏跡宒拻笱跡宒腔暮翹紫ㄛ迵 gzipbzip2 謗笱揤坫楊﹝竭嗣最宒飲褫眕蚚 Apache 眈敯Ъ撐絡鯓蝦Ъ慫畏 CUPSProFTPDPure-FTPd…脹ㄛ arclog 珩褫眕寥紫涴虳 Apache 眈搛鯓蔥躁Ъ撐窗

- - -

蛁砩岈砐

- -
    -
  • 寥濬暮翹紫竭瘧奀潔﹝峈熬屾梩蚚埻暮翹紫腔奀潔ㄛ arclog 頗珂參埻暮翹紫葩秶善婃奀馱釬紫ㄛ弝剒猁參埻暮翹紫寥錨ㄛ婬鞣鞣婓婃奀馱釬紫奻釬珛﹝祥徹堌鄶D瑳臏倇蟠謑

    -
      -
    1. 蝜埻暮翹紫竭湮ㄗ疑撓啃 MB ㄘㄛ嫖葩秶紫偶憩竭豪奀潔賸﹝涴笱①錶狟ㄛ郔疑珂壽敕暮翹最宒ㄛ脹淕燴俇眕綴ㄛ婬樟哿暮翹ㄛ眕旌轎暮翹渣觴﹝蠑蔔衄隅ぶ寥紫ㄛ暮翹紫憩祥頗拸癹秶壩梠賸﹝

    2. -
    3. arclog 硒俴善珨圉秪嘟笢剿ㄛ頗隱狟紹湔腔婃奀馱釬紫﹝梣 arclog 硒俴奀ㄛ癲善眳ヶ紹湔腔婃奀馱釬紫ㄛ頗礿砦硒俴﹝猁珂揭燴裁眳ヶ腔婃奀馱釬紫ㄛ符夔樟哿﹝婃奀馱釬紫硐岆埻紫腔葩掛ㄛ硐猁蜊跺紫靡婬寥紫珨棒ㄛ憩褫眕賸﹝

    4. -
    -
  • - -
  • 羶衄杻梗燴蚕ㄛ郔疑祥猁齬唗﹝齬唗腔Д婓恀枙覤瞿

    -
      -
    1. 暮翹紫竭湮奀ㄛ齬唗頗勛裁竭嗣暮砪极﹝垀剒暮砪极甡寥紫綴藩跺堎暮翹捩杅奧隅﹝陔唳腔 LinuxMS-Windows 炵苀衄暮砪极瘧蚚悵誘ㄛ頗笢剿勛裁怮嗣暮砪极腔最宒ㄛ祥徹涴遜岆猁豪疑撓煦笘ㄛ涴撓煦笘囀炵苀頗俇奏接聹辣砥扂祥眭耋梗腔釬珛炵苀衄羶衄暮砪极瘧蚚悵誘﹝蝜斕猁俙ㄛ瑞玸赻蛹﹝

    2. -
    3. 垀衄盓堔腔暮翹紫跡宒ㄛ奀潔郔苤等弇峈﹝肮珨鏃囀腔暮翹頗珂眕暮翹紫佼唗ㄗ觷畎措曀絢羹虜鶻Ъ撐童岡皈棴埮Ъ摹導穖鼘硉譬恦艣瓚礡涴欴扢數鴃褫夔藷瓚罋曀絢鯢皆酵踽痤躁Ъ撈恦礗牯虮翹淩淏腔楷汜佼唗珨祡ㄛ筍珩拸楊俇垮痐﹝觷皆酵踽痤騫翹棒唗竭笭猁ㄛ斕猁赻俴苤陑﹝

    4. -
    -
  • - -
  • 寥紫 SyslogNTP 暮翹紫奀ㄛ③杻梗蛁砩ㄩ SyslogNTP 暮翹紫羶衄暮爛﹝ arclogDate::Parse 耀郪賤黍奀潔﹝拸爛爺奀ㄛ Date::Parse 頗參爛爺扢婓涴跺堎汁窱鰍繡齤眳潔﹝瞰蝤畏蘀鯄壖 2001-06-08 ㄛ饒爛爺頗扢婓 2001-06-30 善 2000-07-01 眳潔﹝扂埻寀奻婝傖涴欴﹝祥徹ㄛ蠙蒫 SyslogNTP 暮翹紫閉徹珨爛淕燴寥紫ㄛ祥猁變 arclog ㄛ瘁寀暮翹紫頗湮觴﹝

  • - -
  • 植梓袧怀賱謎Ъ撐童甭鄶D瑳臏倇蟠謑

    -
      -
    1. 譣甽螫縢暱靿諴狡迗辣例罔頞邦曀脾悵炸腕腔羲芛ㄛ祥輔閥玥殮劗晶曀絢鯜玫瘚衝釋懟央

    2. -
    3. 梓袧怀輷瑀享噫﹜寥錨麼悵隱窒爺囀搳譣甽螫縢暱靿諴皈音絞隱耀宒頗赻雄豖隙傖垓膨隱﹝珨棒黍賱鉞脾悵畏蠑馺倬訇縢暱靿諴牴愻鄞奼侄媩垓膨隱ㄛ眕旌轎髦觴﹝

    4. -
    5. ask 耀宒腔隙湘珩岆植梓袧怀賱蟋纂秪峈梓袧怀鄵閨倷遘鬕畋麤埭荓縢暱靿賱蟋脾悵疥瑀乳 ask 耀宒ㄛ頗赻雄豖隙善 fail 耀宒﹝

    6. -
    -
  • - -
  • 扂膘祜假蚾 File::MMagic ㄛ鴃講祥猁蚚 file 最宒﹝ File::MMagic 囀膘腔紫偶濬倰桶疑砉掀 file 最宒袧楚聹銘 gzipbzip2 揤坫紫ㄛ arclog 頗參弝峈絞傖曾恅趼紫﹝譨嘈黤絞銜鬌倛肺撐童 arclog 頗絞傖曾恅趼紫ㄛ眻諉黍暮翹ㄛ甜眕渣昫賦旰﹝憩呾渣昫珩祥頗讀觴埻暮翹紫ㄛ祥徹嗣屾衄萸鎊歲﹝

  • -
- - -

炵苀剒⑴

- -
    -
  1. Perl 5.8.0 眕奻﹝ arclog 蚚跺統杅腔 open() 懂葩秶紫偶紱釬ㄛ扂遜祥眭耋崋繫蜊迡善載婌腔唳掛奻硒俴﹝蠙蒧奿堋鹹斯螂婌腔唳掛奻硒俴ㄛ③豢咂扂﹝斕褫眕怀 perl -v 脤戙斕醴ヶ腔 Perl 唳掛﹝蝜斕羶衄 Perl 麼剒猁汔撰ㄛ褫眕善 Perl 厙桴狟婥假蚾郔陔唳 Perl ﹝蠙蒘к MS-Windows ㄛ褫眕善 ActiveState 鼠侗狟婥 ActivePerl 假蚾﹝

  2. - -
  3. 剒減饜腔 Perl 耀郪ㄩ

    - -
    -
    Date::Parse
    - -
    -

    涴岆望妎暮翹奀潔蚚腔﹝斕褫眕CPAN 耀郪踱狟婥假蚾 Date::Parse ㄛ麼蚚 CPAN Shell 硒俴 cpan Date::Parse 假蚾ㄛ麼蚚 CPANPLUS Shell 硒俴 cpanp i Date::Parse 假蚾﹝蠙蒘 Debian/Ubandu Linux 妏蚚氪ㄛ褫眕硒俴 apt-get install libtimedate-perl 假蚾﹝蠙蒘 Red Hat/Fedora/CentOS Linux 妏蚚氪ㄛ褫眕硒俴 yum install perl-TimeDate 假蚾﹝蠙蒘 FreeBSD 妏蚚氪ㄛ褫眕硒俴 ports install p5-TimeDate 假蚾﹝蠙蒘 ActivePerl 妏蚚氪ㄛ褫眕硒俴 ppm install Date::Parse 假蚾﹝

    -
    -
    -
  4. - -
  5. 恁饜腔 Perl 耀郪ㄩ

    - -
    -
    File::MMagic
    - -
    -

    涴岆潰脤紫偶濬倰蚚腔﹝藽閨訄終除 arclog 頗梑 file 最宒測杸﹝藾塹珩輓膛 arclog 頗蜊蚚紫帣ㄗ萵紫靡ㄘ瓚剿紫偶濬倰﹝涴奀臙荓縢暱靿賱蟋童 arclog 憩拸楊瓚剿賸﹝斕褫眕CPAN 耀郪踱狟婥假蚾 File::MMagic ㄛ麼蚚 CPAN Shell 硒俴 cpan File::MMagic 假蚾ㄛ麼蚚 CPANPLUS Shell 硒俴 cpanp i File::MMagic 假蚾﹝蠙蒘 Debian/Ubandu Linux 妏蚚氪ㄛ褫眕硒俴 apt-get install libfile-mmagic-perl 假蚾﹝蠙蒘 Red Hat/Fedora/CentOS Linux 妏蚚氪ㄛ褫眕硒俴 yum install perl-File-MMagic 假蚾﹝蠙蒘 FreeBSD 妏蚚氪ㄛ褫眕硒俴 ports install p5-File-MMagic 假蚾﹝蠙蒘 ActivePerl 妏蚚氪ㄛ褫眕硒俴 ppm install File::MMagic 假蚾﹝蠙蒰肴 MS-Windows 狟妏蚚 file.exe 最宒ㄛ褫眕蚕 GnuWin32 厙桴狟婥﹝③溜珫謹媞鞶炭瘚菠硨腴陬鐃溝剿瞿炸腕峈 file.exe

    - -

    膘祜蚚 File::MMagicfile 最宒髒嫌頗昫瓚﹝

    -
    - -
    Compress::Zlib
    - -
    -

    涴岆揭燴 gzip 揤坫紫蚚腔ㄛ硐衄婓揭燴 gzip 揤坫紫符頗蚚善﹝譣肩蟾掙閨訄終除 arclog 頗彸翍蜊蚚 gzip 最宒測杸﹝藾塹珩輓膛 arclog 憩拸楊硒俴﹝斕褫眕CPAN 耀郪踱狟婥假蚾 Compress::Zlib ㄛ麼蚚 CPAN Shell 硒俴 cpan Compress::Zlib 假蚾ㄛ麼蚚 CPANPLUS Shell 硒俴 cpanp i Compress::Zlib 假蚾﹝蠙蒘 Debian/Ubandu Linux 妏蚚氪ㄛ褫眕硒俴 apt-get install libcompress-zlib-perl 假蚾﹝蠙蒘 Red Hat/Fedora/CentOS Linux 妏蚚氪ㄛ褫眕硒俴 yum install perl-Compress-Zlib 假蚾﹝蠙蒘 FreeBSD 妏蚚氪ㄛ褫眕硒俴 ports install p5-Compress-Zlib 假蚾﹝蠙蒘 ActivePerl 妏蚚氪ㄛ褫眕硒俴 ppm install Compress::Zlib 假蚾﹝蠙蒰肴 MS-Windows 狟妏蚚 gzip.exe 最宒ㄛ褫眕蚕 gzip 厙桴狟婥﹝③溜珫謹媞鞶炭瘚菠硨腴陬鐃溝剿瞿炸腕峈 gzip.exe

    -
    - -
    Compress::Bzip2 菴媼唳眕奻
    - -
    -

    涴岆揭燴 bzip2 揤坫紫蚚腔ㄛ硐衄婓揭燴 bzip2 揤坫紫符頗蚚善﹝譣肩蟾掙閨訄終除 arclog 頗彸翍蜊蚚 bzip2 最宒測杸﹝藾塹珩輓膛 arclog 憩拸楊硒俴﹝斕褫眕CPAN 耀郪踱狟婥假蚾 Compress::Bzip2 ㄛ麼蚚 CPAN Shell 硒俴 cpan Compress::Bzip2 假蚾ㄛ麼蚚 CPANPLUS Shell 硒俴 cpanp i Compress::Bzip2 假蚾﹝蠙蒘 Debian/Ubandu Linux 妏蚚氪ㄛ褫眕硒俴 apt-get install libcompress-bzip2-perl 假蚾﹝蠙蒘 Red Hat/Fedora/CentOS Linux 妏蚚氪ㄛ褫眕硒俴 yum install perl-Compress-Bzip2 假蚾﹝蠙蒘 FreeBSD 妏蚚氪ㄛ褫眕硒俴 ports install p5-Compress-Bzip2 假蚾﹝蠙蒘 ActivePerl 妏蚚氪ㄛ褫眕硒俴 ppm install Compress::Bzip2 假蚾﹝蠙蒰肴 MS-Windows 狟妏蚚 bzip2.exe 最宒ㄛ褫眕蚕 bzip2 厙桴狟婥﹝③溜珫謹媞鞶炭瘚菠硨腴陬鐃溝剿瞿炸腕峈 bzip2.exe

    -
    - -
    Term::ReadKey
    - -
    -

    涴岆珆尨輛僅蹈蚚腔ㄛ藽閨訄終除狡芠遙慺埰噬禷蹈﹝森俋祥頗衄庥恄帎漶ˊ禷蹈褫眕藥蒹 arclog 腔馱釬輛僅珨醴賸說斕褫眕CPAN 耀郪踱狟婥假蚾 Term::ReadKey ㄛ麼蚚 CPAN Shell 硒俴 cpan Term::ReadKey 假蚾ㄛ麼蚚 CPANPLUS Shell 硒俴 cpanp i Term::ReadKey 假蚾﹝蠙蒘 Debian/Ubandu Linux 妏蚚氪ㄛ褫眕硒俴 apt-get install libterm-readkey-perl 假蚾﹝蠙蒘 Red Hat/Fedora/CentOS Linux 妏蚚氪ㄛ褫眕硒俴 yum install perl-TermReadKey 假蚾﹝蠙蒘 FreeBSD 妏蚚氪ㄛ褫眕硒俴 ports install p5-Term-ReadKey 假蚾﹝蠙蒘 ActivePerl 妏蚚氪ㄛ褫眕硒俴 ppm install Term::ReadKey 假蚾﹝

    -
    -
    -
  6. -
- - -

狟婥

- -

arclog 腔夥源厙桴婓ㄩ

- - - -

郔陔唳 arclog 褫蚕狟蹈弇硊狟婥ㄩ

- - - -

甡鎖癡腔 PGP 鼠埥婓ㄩ

- - - - -

假蚾

- -

蠙蒘к arclog.pl 2.1.1dev4 眕ヶ腔唳掛汔撰ㄛ③統堐 UPGRADE.zh-cn 紫腔汔撰佽隴﹝

- -

ExtUtils::MakeMaker 假蚾

- -

arclogPerl 梓袧腔 ExtUtils::MakeMaker 假蚾ㄛ最唗覤瞿

- -
-% perl Makefile.PL
-% make
-% make test
-% make install
-
- -

make install ヶㄛ③珂溜狦蒑俶痚終凰螞撈瘚紫饑使煄籵都涴奀緊猁з遙峈 root ㄛ符夔假蚾湔紫﹝

- -

蠙蒘к MS-Windows 狟腔 ActivePerlmake ③蜊蚚 nmakenmake 褫蚕峚穔 FTP 桴狟婥

- -

譣狐終做複頖華源ㄛ③扢隅疑 PREFIX ﹝瞰蝤皆趕蒘墓譏舝皆狐終啪稊埮熊闡螞樞薹悵

- -
-% perl Makefile.PL PREFIX=/home/jessica
-
- -

猁眭耋載嗣假蚾恁砐腔牉誹ㄛ③統堐 ExtUtils::MakeMaker 腔佽隴ㄗ③硒俴 perldoc ExtUtils::MakeMaker ㄘ﹝

- - -

Module::Build 假蚾

- -

蠙蓔祥閎皆窒奿娸 Module::Build 假蚾ㄛ最唗覤瞿

- -
-% perl Build.PL
-% ./Build
-% ./Build test
-% ./Build install
-
- -

./Build install ヶㄛ③珂溜狦蒑俶痚終凰螞撈瘚紫饑使煄籵都涴奀緊猁з遙峈 root ㄛ符夔假蚾湔紫﹝

- -

譣狐終做複頖華源ㄛ③扢隅疑 --prefix ﹝瞰蝤皆趕蒘墓譏舝皆狐終啪稊埮熊闡螞樞薹悵

- -
-% perl Build.PL --prefix=/home/jessica
-
- -

猁眭耋載嗣假蚾恁砐腔牉誹ㄛ③統堐 Module::Build 腔佽隴ㄗ③硒俴 perldoc Module::Build ㄘ﹝

- - -

韜鍔蹈統杅

- -
-./arclog [統杅] 暮翹紫紫靡… [寥紫紫靡羲芛]
-./arclog [-h|-v]
-
- - -
-
暮翹紫紫靡
- -
-

猁淕燴寥紫腔暮翹紫紫靡﹝譣玫荓縢暱靿賱謎Ъ撐童甭輶頞迅 - ﹝褫肮奀硌隅勍嗣紫偶﹝盓堔 gzipbzip2 揤坫紫﹝

-
- - -
寥紫紫靡羲芛
- -
-

寥紫紫靡蚚腔羲芛ㄛ寥紫綴腔紫偶頗 ̄請羲芛.yymmddㄛ蝤羲芛.200101羲芛.200102 …脹﹝蝜羶衄扢隅ㄛ頗蚚暮翹紫腔紫靡絞羲芛﹝蠙蒰玫荓縢暱靿賱謎Ъ撐童狡迗辣例罔頩曀紫腕羲芛﹝涴爵祥夔蚚 - ㄗ梓袧怀諴岡皆藬肪熏懭頞巡騫З腕腔羲芛ㄛ祥岆紫靡﹝

-
- - -
-c, --compress 揤坫楊
- -
-

扢隅寥紫蚚腔揤坫楊﹝暮翹湮嗣飲酗腕竭砉ㄛ揤坫裁頗吽狟準都嗣腔諾潔﹝ㄗ祥遘匟儮曀童 ^_*’ ㄘ醴ヶ盓堔狟蹈腔揤坫楊ㄩ

- - -
-
g, gzip
- -
-

gzip 揤坫﹝啎扢岆蚚 gzip 揤坫﹝ arclog 褫眕蚚 Compress::Zlib 懂測杸 gzip 揤坫ㄛ祥蚚網請俋窒最宒ㄛ掀誕辦掀誕假哄ㄡ遜蝜斕羶衄蚾 Compress::Zlibarclog 遜岆頗赻撩蜊蚚 gzip 最宒揤坫﹝筍蝜蟀 gzip 最宒飲羶衄ㄛ棍肩繭 gzip 揤坫ㄛ憩羶衄域楊賸ㄛ拸楊硒俴﹝

-
- - -
b, bzip2
- -
-

bzip2 揤坫﹝ arclog 褫眕蚚 Compress::Bzip2 懂測杸 bzip2 揤坫ㄛ祥蚚網請俋窒最宒ㄛ掀誕辦掀誕假哄ㄡ遜蝜斕羶衄蚾 Compress::Bzip2arclog 遜岆頗赻撩蜊蚚 bzip2 最宒揤坫﹝筍蝜蟀 bzip2 最宒飲羶衄ㄛ棍肩繭 bzip2 揤坫ㄛ憩羶衄域楊賸ㄛ拸楊硒俴﹝

-
- - -
n, none
- -
-

祥猁揤坫﹝ㄗ斕羶詻渣勘ˋ :p ㄘ

-
-
-
- - -
--nocompress
- -
-

寥紫綴祥猁揤坫ㄛ虴彆睿 --compress none 珨欴﹝

-
- - -
-s, --sort
- -
-

偌暮翹奀潔珂綴ㄗ摯暮翹掛旯佼唗ㄘ齬唗﹝齬唗竭瘧暮砪极睿 CPU ㄛ垀眕啎扢岆祥齬唗﹝③統獗ヶ醱壽黺齬唗腔蛁砩岈砐﹝

-
- - -
--nosort
- -
-

祥猁齬唗ㄗ啎扢硉ㄘ﹝

-
- - -
-o, --override 耀宒
- -
-

蝜衄肮靡腔導紫ㄛ蜆崋繫域﹝醴ヶ衄狟蹈耀宒ㄩ

- - -
-
o, overwrite
- -
-

裔裁導紫﹝導紫腔暮翹頗掩刉裁ㄛ③嗣樓苤陑﹝蠙蒫躁Ъ撐脾н鷐Ъ撐童皇倜鎡縕腔暮翹ㄛ斕褫眕蚚 overwrite

-
- - -
a, append
- -
-

睿導紫樓婓珨れ﹝涴衄褫夔頗栳曹傖湮髦觴ㄛ③嗣樓苤陑﹝蠙蓔諻捘蔆搚銓畎掉鉾躁Ъ撐絳衲祴酴艞珀蒧奿娸 append

-
- - -
i, ignore
- -
-

謹徹垀衄蜆堎腔暮翹﹝涴衄褫夔婖傖窒爺暮翹霜囮ㄛ③嗣樓苤陑﹝蠙蜣閡玨像鞀閨邿曀紫齟繚搟珀蒧奿娸 ignore

-
- - -
f, fail
- -
-

賦旰最宒ㄛ眕轎祥苤陑ぢ輓導紫﹝蠙蒰肩 crontab 眳濬腔最宒ㄛ度堈粉胱棣苺盃蹎譏瑵灥皆埼牓し菁岏洁秪森ㄛ翿縢暱靿貒銘Щ炸蝦攫奻ㄛ啎扢岆 fail

-
- - -
ask
- -
-

恀斕蜆崋繫域﹝蠙蒘в硍胱棣苺盈瑵郔源晞﹝秪森ㄛ翿縢暱靿輮Щ炸蝦攫奻ㄛ啎扢岆 ask ﹝湘偶岆植梓袧怀賱蟋纂秪峈梓袧怀鄵閨倷遘鬕畏蠙蒰玫荓縢暱靿賱謎Ъ撐童炬酸凗 ask 耀宒ㄛ頗赻雄豖隙 fail 耀宒﹝遜衄ㄛ蝜植梓袧怀賱螻輓蓿屋驐疢 crontab 爵梓袧怀貑遜媯蘅芄皆祥戧堈翅侄 fail 耀宒﹝

-
-
-
- - -
-k, --keep 耀宒
- -
-

埻暮翹紫猁崋繫揭燴﹝醴ヶ衄狟蹈耀宒ㄩ

- - -
-
a, all
- -
-

俇垮隱埻紫﹝

-
- - -
r, restart
- -
-

寥紫綴ㄛ埻暮翹紫寥錨﹝

-
- - -
d, delete
- -
-

寥紫綴ㄛ刉壺埻暮翹紫﹝

-
- - -
t, this-month
- -
-

蔚眳ヶ堎爺腔暮翹寥紫ㄛ悵隱涴跺堎腔暮翹ㄛ隱渾狟跺堎寥紫﹝涴岆跤 crontab 藩堎寥紫蚚腔﹝秪森ㄛ啎扢岆 this-month

-
-
- -
- - -
-d, --debug
- -
-

珆尨砆牉腔硒俴徹最﹝

-
- - -
-q, --quiet
- -
-

羶岈祥猁陶﹝ :p

-
- - -
-h, --help
- -
-

珆尨最宒佽隴﹝

-
- - -
-v, --version
- -
-

珆尨最宒唳掛﹝

-
-
- - -

唳享驨

- -

唳佯齾 © 2001-2007 甡鎖癡﹝

- -

掛最宒岆赻蚕篱憯珀褫眕郩桽赻蚕篱撱虌蟧 (Free Software Foundation) 堤唳腔 GNU 籵蚚鼠僕勍褫痐沭遴 (GNU General Public License) 菴唳懂党蜊睿笭陔楷票涴珨最宒ㄛ麼氪赻蚕恁寁妏蚚庥庛陔腔唳掛﹝

- -

楷票涴珨最宒腔醴腔岆洷咡坳衄蚚ㄛ筍羶衄庥庰ㄠㄐ朼祫羶衄巠磁杻隅醴腔奧笐漪腔童悵﹝載砆牉腔①錶③統堐 GNU 籵蚚鼠僕勍褫痐

- -

蠟茼蜆眒冪睿最宒珨れ彶善珨爺 GNU 籵蚚鼠僕勍褫痐腔萵掛﹝蝜遜羶衄ㄛ統堐<http://www.gnu.org/licenses/>

- - -

唳掛槨翹

- -

③堐黍 NEWS 紫ㄛ脤艘最宒腔栳曹﹜陔崝腔髡夔睿党硃腔渣昫﹝

- - -

盓堔衪翑

- -

arclog 厙桴殤婓 SourceForgeCPAN藏忔甡鎖﹝坰=鍤豐庍閎甭趧暕晻

- - - -

SourceForge 奻衄珨跺 arclog 腔蚘璃籵捅 ﹝妏蚚奻腔恀枙﹜膘祜麼渣昫隙惆ㄛ③枑善籵捅奻枒蹦﹝坳岆 Mailman 腔蚘璃籵捅﹝譣盲蚧諴甭賮 arclog 蚘璃籵捅腔厙珜 ﹝斕珩褫眕迡陓善 E-mail 硌鍔陓眊ㄛ梓枙沓奻 help ㄛ坰 E-mail 硌鍔佽隴﹝

- -
- - -
- - - - diff --git a/arclog.zh-tw.html b/arclog.zh-tw.html deleted file mode 100644 index 6542f99..0000000 --- a/arclog.zh-tw.html +++ /dev/null @@ -1,515 +0,0 @@ - - - - - - - - - - - - - - - -arclog 3.04 版 - - - -
- 正體中文 | - 简体中文 | - English -
-
- - -
- - -

arclog 3.04 版

- - -

最新消息

- -
-
2007-12-03
- -
-

arclog 最新版本 3.04 。說明文件修正。若妳之前安裝了 arclog 3.00 版或之後的版本,不需要昇級新版。下載 arclog 3.04 版

-
- - -
2007-12-03
- -
-

arclog 最新版本 3.03 。修正測試套件。所需 Perl 版本號碼改用相容於舊版的號碼格式,以消除 Perl 5.10 的警告訊息。若妳之前安裝了 arclog 3.00 版或之後的版本,不需要昇級新版。下載 arclog 3.03 版

-
- - -
2007-11-30
- -
-

arclog 最新版本 3.02 。修正測試套件,以處理日光節約時間問題。若妳之前安裝了 arclog 3.00 版或之後的版本,不需要昇級新版。下載 arclog 3.02 版

-
- - -
2007-11-28
- -
-

arclog 最新版本 3.01 。修正測試套件,以協助釐清 CPAN 測試回報的錯誤。若妳之前安裝了 arclog 3.00 版,不需要昇級新版。下載 arclog 3.01 版

-
- - -
2007-11-28
- -
-

arclog 最新版本 3.00 。從 reslog 借過來的全新程式碼,檔名也從 arclog.pl 改為 arclog 。新的物件導向處理器,可順利處理各種壓縮法及檔案格式。安裝系統由 GNU autoconf 改用 PerlExtUtils::MakeMakerModule::Build 。新加上完整的測試套件,協助程式品管。版權更新為 GPLv3下載 arclog 3.00 版

-
- - -
2002-09-26
- -
-

arclog.pl 最新版本 2.1.0 。這是 2.1.0 的最終版,加上了 bzip2 壓縮的支援,用 gzip 程式代替 Compress::Zlib 壓縮,並改用 GNU autoconf 安裝設定程式。下載 arclog.pl 2.1.0

-
- - -
2002-09-18
- -
-

arclog.pl 最新版本 2.1.0dev2 。本版修正了幾個說明文件的錯誤,並把 SourceForge 加進 arclog.pl 的下載網址中。妳可以把它當做申請 SourceForge 紀念版。原則上,不需要急著昇級。下載 arclog.pl 2.1.0dev2

-
- - -
2002-09-17
- -
-

好消息! arclog.pl 已開始架設於 SourceForge 囉!(雖然我幾乎還完全搞不清楚要怎麼架…摸索中… ^^; )

-
-
- - - -

說明

- -

arclog 是記錄檔每月歸檔程式,將記錄檔中,前月的記錄按月份壓縮歸檔,以節省硬碟空間,並避免記錄檔被有心人士破壞。

- -

arclog 目前支援 ApacheSyslogNTPApache 1 SSL engine log 及我自己用的括弧 ISO 修正格式五種格式的記錄檔,與 gzipbzip2 兩種壓縮法。很多程式都可以用 Apache 相容記錄檔格式記錄,如 CUPSProFTPDPure-FTPd…等, arclog 也可以歸檔這些 Apache 相容格式的記錄檔。

- - -

注意事項

- -
    -
  • 歸類記錄檔很耗時間。為減少佔用原記錄檔的時間, arclog 會先把原記錄檔複製到暫時工作檔,視需要把原記錄檔歸零,再慢慢在暫時工作檔上作業。不過仍請注意下列事項:

    -
      -
    1. 如果原記錄檔很大(好幾百 MB ),光複製檔案就很花時間了。這種情況下,最好先關閉記錄程式,等整理完以後,再繼續記錄,以避免記錄錯亂。若平常有定期歸檔,記錄檔就不會無限制膨脹了。

    2. -
    3. arclog 執行到一半因故中斷,會留下殘存的暫時工作檔。日後 arclog 執行時,碰到之前殘存的暫時工作檔,會停止執行。要先處理掉之前的暫時工作檔,才能繼續。暫時工作檔只是原檔的複本,只要改個檔名再歸檔一次,就可以了。

    4. -
    -
  • - -
  • 沒有特別理由,最好不要排序。排序的潛在問題如下:

    -
      -
    1. 記錄檔很大時,排序會吃掉很多記憶體。所需記憶體依歸檔後每個月記錄筆數而定。新版的 LinuxMS-Windows 系統有記憶體耗用保護,會中斷吃掉太多記憶體的程式,不過這還是要花好幾分鐘,這幾分鐘內系統會完全當掉不動。我不知道別的作業系統有沒有記憶體耗用保護。如果妳要玩,風險自負。

    2. -
    3. 所有支援的記錄檔格式,時間最小單位為。同一秒內的記錄會先以記錄檔順序(若同時歸檔好幾個記錄檔),再以記錄本身出現的次序排序。這樣設計儘可能讓排序歸檔後同一秒內的記錄次序,和事件真正的發生順序一致,但也無法完全保證。若同一秒內的事件次序很重要,妳要自行小心。

    4. -
    -
  • - -
  • 歸檔 SyslogNTP 記錄檔時,請特別注意: SyslogNTP 記錄檔沒有記年。 arclogDate::Parse 模組解讀時間。無年份時, Date::Parse 會把年份設在這個月去年的下個月之間。例如,若今天是 2001-06-08 ,那年份會設在 2001-06-30 到 2000-07-01 之間。我原則上贊成這樣。不過,若妳的 SyslogNTP 記錄檔超過一年整理歸檔,不要跑 arclog ,否則記錄檔會大亂。

  • - -
  • 從標準輸入讀記錄檔,請注意下列事項:

    -
      -
    1. 若要讀標準輸入,就一定要設定歸檔時,檔名的開頭,不然不知道怎麼歸檔後要存到哪堨h。

    2. -
    3. 標準輸入無法刪除、歸零或保留部份內容。若要讀標準輸入,原檔保留模式會自動退回成全部保留。一次讀入多檔時,若其中有標準輸入,會一律退回全部保留,以避免混亂。

    4. -
    5. ask 模式的回答也是從標準輸入讀的。因為標準輸入只有一個,所以從標準輸入讀檔時,無法跑 ask 模式,會自動退回到 fail 模式。

    6. -
    -
  • - -
  • 我建議安裝 File::MMagic ,儘量不要用 file 程式。 File::MMagic 內建的檔案類型表好像比 file 程式準確。若不是 gzipbzip2 壓縮檔, arclog 會把視為當成純文字檔。若壓縮檔被誤判為圖檔, arclog 會當成純文字檔,直接讀記錄,並以錯誤結束。就算錯誤也不會弄亂原記錄檔,不過多少有點麻煩。

  • -
- - -

系統需求

- -
    -
  1. Perl 5.8.0 以上。 arclog 用三個參數的 open() 來複製檔案操作,我還不知道怎麼改寫到更早的版本上執行。若妳可以改寫到更早的版本上執行,請告訴我。妳可以輸入 perl -v 查詢妳目前的 Perl 版本。如果妳沒有 Perl 或需要昇級,可以到 Perl 網站下載安裝最新版 Perl 。若妳是用 MS-Windows ,可以到 ActiveState 公司下載 ActivePerl 安裝。

  2. - -
  3. 需搭配的 Perl 模組:

    - -
    -
    Date::Parse
    - -
    -

    這是辨識記錄時間用的。妳可以CPAN 模組庫下載安裝 Date::Parse ,或用 CPAN Shell 執行 cpan Date::Parse 安裝,或用 CPANPLUS Shell 執行 cpanp i Date::Parse 安裝。若妳是 Debian/Ubandu Linux 使用者,可以執行 apt-get install libtimedate-perl 安裝。若妳是 Red Hat/Fedora/CentOS Linux 使用者,可以執行 yum install perl-TimeDate 安裝。若妳是 FreeBSD 使用者,可以執行 ports install p5-TimeDate 安裝。若妳是 ActivePerl 使用者,可以執行 ppm install Date::Parse 安裝。

    -
    -
    - -

    若妳由 CPANCPANPLUS Shell 安裝 arclog ,會自動幫妳安裝以上所需的模組。

    -
  4. - -
  5. 選配的 Perl 模組:

    - -
    -
    File::MMagic
    - -
    -

    這是檢查檔案類型用的。若沒有安裝, arclog 會找 file 程式代替。若還找不到, arclog 會改用檔尾(副檔名)判斷檔案類型。這時若從標準輸入讀檔, arclog 就無法判斷了。妳可以CPAN 模組庫下載安裝 File::MMagic ,或用 CPAN Shell 執行 cpan File::MMagic 安裝,或用 CPANPLUS Shell 執行 cpanp i File::MMagic 安裝。若妳是 Debian/Ubandu Linux 使用者,可以執行 apt-get install libfile-mmagic-perl 安裝。若妳是 Red Hat/Fedora/CentOS Linux 使用者,可以執行 yum install perl-File-MMagic 安裝。若妳是 FreeBSD 使用者,可以執行 ports install p5-File-MMagic 安裝。若妳是 ActivePerl 使用者,可以執行 ppm install File::MMagic 安裝。若妳要在 MS-Windows 下使用 file.exe 程式,可以由 GnuWin32 網站下載。請確認下載後,存檔在系統的路徑下,檔名為 file.exe

    - -

    建議用 File::MMagicfile 程式偶爾會誤判。

    -
    - -
    Compress::Zlib
    - -
    -

    這是處理 gzip 壓縮檔用的,只有在處理 gzip 壓縮檔才會用到。若要用時沒有安裝, arclog 會試著改用 gzip 程式代替。若還找不到, arclog 就無法執行。妳可以CPAN 模組庫下載安裝 Compress::Zlib ,或用 CPAN Shell 執行 cpan Compress::Zlib 安裝,或用 CPANPLUS Shell 執行 cpanp i Compress::Zlib 安裝。若妳是 Debian/Ubandu Linux 使用者,可以執行 apt-get install libcompress-zlib-perl 安裝。若妳是 Red Hat/Fedora/CentOS Linux 使用者,可以執行 yum install perl-Compress-Zlib 安裝。若妳是 FreeBSD 使用者,可以執行 ports install p5-Compress-Zlib 安裝。若妳是 ActivePerl 使用者,可以執行 ppm install Compress::Zlib 安裝。若妳要在 MS-Windows 下使用 gzip.exe 程式,可以由 gzip 網站下載。請確認下載後,存檔在系統的路徑下,檔名為 gzip.exe

    -
    - -
    Compress::Bzip2 第二版以上
    - -
    -

    這是處理 bzip2 壓縮檔用的,只有在處理 bzip2 壓縮檔才會用到。若要用時沒有安裝, arclog 會試著改用 bzip2 程式代替。若還找不到, arclog 就無法執行。妳可以CPAN 模組庫下載安裝 Compress::Bzip2 ,或用 CPAN Shell 執行 cpan Compress::Bzip2 安裝,或用 CPANPLUS Shell 執行 cpanp i Compress::Bzip2 安裝。若妳是 Debian/Ubandu Linux 使用者,可以執行 apt-get install libcompress-bzip2-perl 安裝。若妳是 Red Hat/Fedora/CentOS Linux 使用者,可以執行 yum install perl-Compress-Bzip2 安裝。若妳是 FreeBSD 使用者,可以執行 ports install p5-Compress-Bzip2 安裝。若妳是 ActivePerl 使用者,可以執行 ppm install Compress::Bzip2 安裝。若妳要在 MS-Windows 下使用 bzip2.exe 程式,可以由 bzip2 網站下載。請確認下載後,存檔在系統的路徑下,檔名為 bzip2.exe

    -
    - -
    Term::ReadKey
    - -
    -

    這是顯示進度列用的,若沒有安裝,就不會顯示進度列。此外不會有任何問題。進度列可以讓妳對 arclog 的工作進度一目瞭然。妳可以CPAN 模組庫下載安裝 Term::ReadKey ,或用 CPAN Shell 執行 cpan Term::ReadKey 安裝,或用 CPANPLUS Shell 執行 cpanp i Term::ReadKey 安裝。若妳是 Debian/Ubandu Linux 使用者,可以執行 apt-get install libterm-readkey-perl 安裝。若妳是 Red Hat/Fedora/CentOS Linux 使用者,可以執行 yum install perl-TermReadKey 安裝。若妳是 FreeBSD 使用者,可以執行 ports install p5-Term-ReadKey 安裝。若妳是 ActivePerl 使用者,可以執行 ppm install Term::ReadKey 安裝。

    -
    -
    -
  6. -
- - -

下載

- -

arclog 的官方網站在:

- - - -

最新版 arclog 可由下列位址下載:

- - - -

依瑪貓的 PGP 公鑰在:

- - - - -

安裝

- -

若妳是由 arclog.pl 2.1.1dev4 以前的版本昇級,請參閱 UPGRADE.zh-tw 檔的昇級說明。

- -

ExtUtils::MakeMaker 安裝

- -

arclogPerl 標準的 ExtUtils::MakeMaker 安裝,程序如下:

- -
-% perl Makefile.PL
-% make
-% make test
-% make install
-
- -

make install 前,請先確認妳有在安裝目錄存檔的權限。通常這時候要切換為 root ,才能安裝存檔。

- -

若妳是用 MS-Windows 下的 ActivePerlmake 請改用 nmakenmake 可由微軟的 FTP 站下載

- -

若要安裝到其它地方,請設定好 PREFIX 。例如,一般使用者,要安裝在自己的目錄下時:

- -
-% perl Makefile.PL PREFIX=/home/jessica
-
- -

要知道更多安裝選項的細節,請參閱 ExtUtils::MakeMaker 的說明(請執行 perldoc ExtUtils::MakeMaker )。

- - -

Module::Build 安裝

- -

若妳喜歡,也可以用 Module::Build 安裝,程序如下:

- -
-% perl Build.PL
-% ./Build
-% ./Build test
-% ./Build install
-
- -

./Build install 前,請先確認妳有在安裝目錄存檔的權限。通常這時候要切換為 root ,才能安裝存檔。

- -

若要安裝到其它地方,請設定好 --prefix 。例如,一般使用者,要安裝在自己的目錄下時:

- -
-% perl Build.PL --prefix=/home/jessica
-
- -

要知道更多安裝選項的細節,請參閱 Module::Build 的說明(請執行 perldoc Module::Build )。

- - -

命令列參數

- -
-./arclog [參數] 記錄檔檔名… [歸檔檔名開頭]
-./arclog [-h|-v]
-
- - -
-
記錄檔檔名
- -
-

要整理歸檔的記錄檔檔名。若要從標準輸入讀記錄檔,請設定成 - 。可同時指定許多檔案。支援 gzipbzip2 壓縮檔。

-
- - -
歸檔檔名開頭
- -
-

歸檔檔名用的開頭,歸檔後的檔案會取名叫開頭.yymmdd,如:開頭.200101開頭.200102 …等。如果沒有設定,會用記錄檔的檔名當開頭。若妳要從標準輸入讀記錄檔,就一定要設歸檔檔名開頭。這堣ㄞ鄍 - (標準輸入),因為這堻]定的是檔名的開頭,不是檔名。

-
- - -
-c, --compress 壓縮法
- -
-

設定歸檔用的壓縮法。記錄大多都長得很像,壓縮掉會省下非常多的空間。(不然幹嘛歸檔? ^_*’ )目前支援下列的壓縮法:

- - -
-
g, gzip
- -
-

gzip 壓縮。預設是用 gzip 壓縮。 arclog 可以用 Compress::Zlib 來代替 gzip 壓縮,不用呼叫外部程式,比較快比較安全。不過如果妳沒有裝 Compress::Zlibarclog 還是會自己改用 gzip 程式壓縮。但如果連 gzip 程式都沒有,卻要用到 gzip 壓縮,就沒有辦法了,無法執行。

-
- - -
b, bzip2
- -
-

bzip2 壓縮。 arclog 可以用 Compress::Bzip2 來代替 bzip2 壓縮,不用呼叫外部程式,比較快比較安全。不過如果妳沒有裝 Compress::Bzip2arclog 還是會自己改用 bzip2 程式壓縮。但如果連 bzip2 程式都沒有,卻要用到 bzip2 壓縮,就沒有辦法了,無法執行。

-
- - -
n, none
- -
-

不要壓縮。(妳沒搞錯吧? :p )

-
-
-
- - -
--nocompress
- -
-

歸檔後不要壓縮,效果和 --compress none 一樣。

-
- - -
-s, --sort
- -
-

按記錄時間先後(及記錄本身順序)排序。排序很耗記憶體和 CPU ,所以預設是不排序。請參見前面關於排序的注意事項。

-
- - -
--nosort
- -
-

不要排序(預設值)。

-
- - -
-o, --override 模式
- -
-

如果有同名的舊檔,該怎麼辦。目前有下列模式:

- - -
-
o, overwrite
- -
-

蓋掉舊檔。舊檔的記錄會被刪掉,請多加小心。若妳的記錄檔是主記錄檔,有最完整的記錄,妳可以用 overwrite

-
- - -
a, append
- -
-

和舊檔加在一起。這有可能會演變成大混亂,請多加小心。若妳想把兩份不同時間的記錄檔加在一起,妳可以用 append

-
- - -
i, ignore
- -
-

略過所有該月的記錄。這有可能造成部份記錄流失,請多加小心。若妳只要補充沒有歸檔的月份,妳可以用 ignore

-
- - -
f, fail
- -
-

結束程式,以免不小心破壞舊檔。若妳要用 crontab 之類的程式,全自動化執行,最好這樣,以免破壞資料。因此,若標準輸入不是連到鍵盤上,預設是 fail

-
- - -
ask
- -
-

問妳該怎麼辦。若妳是手動執行,這樣最方便。因此,若標準輸入是連到鍵盤上,預設是 ask 。答案是從標準輸入讀的。因為標準輸入只有一個,若妳要從標準輸入讀記錄檔,不能跑 ask 模式,會自動退回 fail 模式。還有,如果從標準輸入讀不到東西,像 crontab 媦郱Ч擗J被關掉了,也會自動退回 fail 模式。

-
-
-
- - -
-k, --keep 模式
- -
-

原記錄檔要怎麼處理。目前有下列模式:

- - -
-
a, all
- -
-

完全保留原檔。

-
- - -
r, restart
- -
-

歸檔後,原記錄檔歸零。

-
- - -
d, delete
- -
-

歸檔後,刪除原記錄檔。

-
- - -
t, this-month
- -
-

將之前月份的記錄歸檔,保留這個月的記錄,留待下個月歸檔。這是給 crontab 每月歸檔用的。因此,預設是 this-month

-
-
- -
- - -
-d, --debug
- -
-

顯示詳細的執行過程。

-
- - -
-q, --quiet
- -
-

沒事不要吵。 :p

-
- - -
-h, --help
- -
-

顯示程式說明。

-
- - -
-v, --version
- -
-

顯示程式版本。

-
-
- - -

版權聲明

- -

版權所有 © 2001-2007 依瑪貓。

- -

本程式是自由軟體,您可以遵照自由軟體基金會 (Free Software Foundation) 出版的 GNU 通用公共許可證條款 (GNU General Public License) 第三版來修改和重新發佈這一程式,或者自由選擇使用任何更新的版本。

- -

發佈這一程式的目的是希望它有用,但沒有任何擔保。甚至沒有適合特定目的而隱含的擔保。更詳細的情況請參閱 GNU 通用公共許可證

- -

您應該已經和程式一起收到一份 GNU 通用公共許可證的副本。如果還沒有,參閱<http://www.gnu.org/licenses/>

- - -

版本紀錄

- -

請閱讀 NEWS 檔,查看程式的演變、新增的功能和修補的錯誤。

- - -

支援協助

- -

arclog 網站架在 SourceForgeCPAN旅舍依瑪。索取最新資訊,請駕臨:

- - - -

SourceForge 上有一個 arclog 的郵件通訊 。使用上的問題、建議或錯誤回報,請提到通訊上討論。它是 Mailman 的郵件通訊。若要加入,請到 arclog 郵件通訊的網頁 。妳也可以寫信到 E-mail 指令信箱,標題填上 help ,索取 E-mail 指令說明。

- -
- - -
- - - - diff --git a/fdl.txt b/fdl.txt deleted file mode 100644 index 4a0fe1c..0000000 --- a/fdl.txt +++ /dev/null @@ -1,397 +0,0 @@ - GNU Free Documentation License - Version 1.2, November 2002 - - - Copyright (C) 2000,2001,2002 Free Software Foundation, Inc. - 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - -0. PREAMBLE - -The purpose of this License is to make a manual, textbook, or other -functional and useful document "free" in the sense of freedom: to -assure everyone the effective freedom to copy and redistribute it, -with or without modifying it, either commercially or noncommercially. -Secondarily, this License preserves for the author and publisher a way -to get credit for their work, while not being considered responsible -for modifications made by others. - -This License is a kind of "copyleft", which means that derivative -works of the document must themselves be free in the same sense. It -complements the GNU General Public License, which is a copyleft -license designed for free software. - -We have designed this License in order to use it for manuals for free -software, because free software needs free documentation: a free -program should come with manuals providing the same freedoms that the -software does. But this License is not limited to software manuals; -it can be used for any textual work, regardless of subject matter or -whether it is published as a printed book. We recommend this License -principally for works whose purpose is instruction or reference. - - -1. APPLICABILITY AND DEFINITIONS - -This License applies to any manual or other work, in any medium, that -contains a notice placed by the copyright holder saying it can be -distributed under the terms of this License. Such a notice grants a -world-wide, royalty-free license, unlimited in duration, to use that -work under the conditions stated herein. The "Document", below, -refers to any such manual or work. Any member of the public is a -licensee, and is addressed as "you". You accept the license if you -copy, modify or distribute the work in a way requiring permission -under copyright law. - -A "Modified Version" of the Document means any work containing the -Document or a portion of it, either copied verbatim, or with -modifications and/or translated into another language. - -A "Secondary Section" is a named appendix or a front-matter section of -the Document that deals exclusively with the relationship of the -publishers or authors of the Document to the Document's overall subject -(or to related matters) and contains nothing that could fall directly -within that overall subject. (Thus, if the Document is in part a -textbook of mathematics, a Secondary Section may not explain any -mathematics.) The relationship could be a matter of historical -connection with the subject or with related matters, or of legal, -commercial, philosophical, ethical or political position regarding -them. - -The "Invariant Sections" are certain Secondary Sections whose titles -are designated, as being those of Invariant Sections, in the notice -that says that the Document is released under this License. If a -section does not fit the above definition of Secondary then it is not -allowed to be designated as Invariant. The Document may contain zero -Invariant Sections. If the Document does not identify any Invariant -Sections then there are none. - -The "Cover Texts" are certain short passages of text that are listed, -as Front-Cover Texts or Back-Cover Texts, in the notice that says that -the Document is released under this License. A Front-Cover Text may -be at most 5 words, and a Back-Cover Text may be at most 25 words. - -A "Transparent" copy of the Document means a machine-readable copy, -represented in a format whose specification is available to the -general public, that is suitable for revising the document -straightforwardly with generic text editors or (for images composed of -pixels) generic paint programs or (for drawings) some widely available -drawing editor, and that is suitable for input to text formatters or -for automatic translation to a variety of formats suitable for input -to text formatters. A copy made in an otherwise Transparent file -format whose markup, or absence of markup, has been arranged to thwart -or discourage subsequent modification by readers is not Transparent. -An image format is not Transparent if used for any substantial amount -of text. A copy that is not "Transparent" is called "Opaque". - -Examples of suitable formats for Transparent copies include plain -ASCII without markup, Texinfo input format, LaTeX input format, SGML -or XML using a publicly available DTD, and standard-conforming simple -HTML, PostScript or PDF designed for human modification. Examples of -transparent image formats include PNG, XCF and JPG. Opaque formats -include proprietary formats that can be read and edited only by -proprietary word processors, SGML or XML for which the DTD and/or -processing tools are not generally available, and the -machine-generated HTML, PostScript or PDF produced by some word -processors for output purposes only. - -The "Title Page" means, for a printed book, the title page itself, -plus such following pages as are needed to hold, legibly, the material -this License requires to appear in the title page. For works in -formats which do not have any title page as such, "Title Page" means -the text near the most prominent appearance of the work's title, -preceding the beginning of the body of the text. - -A section "Entitled XYZ" means a named subunit of the Document whose -title either is precisely XYZ or contains XYZ in parentheses following -text that translates XYZ in another language. (Here XYZ stands for a -specific section name mentioned below, such as "Acknowledgements", -"Dedications", "Endorsements", or "History".) To "Preserve the Title" -of such a section when you modify the Document means that it remains a -section "Entitled XYZ" according to this definition. - -The Document may include Warranty Disclaimers next to the notice which -states that this License applies to the Document. These Warranty -Disclaimers are considered to be included by reference in this -License, but only as regards disclaiming warranties: any other -implication that these Warranty Disclaimers may have is void and has -no effect on the meaning of this License. - - -2. VERBATIM COPYING - -You may copy and distribute the Document in any medium, either -commercially or noncommercially, provided that this License, the -copyright notices, and the license notice saying this License applies -to the Document are reproduced in all copies, and that you add no other -conditions whatsoever to those of this License. You may not use -technical measures to obstruct or control the reading or further -copying of the copies you make or distribute. However, you may accept -compensation in exchange for copies. If you distribute a large enough -number of copies you must also follow the conditions in section 3. - -You may also lend copies, under the same conditions stated above, and -you may publicly display copies. - - -3. COPYING IN QUANTITY - -If you publish printed copies (or copies in media that commonly have -printed covers) of the Document, numbering more than 100, and the -Document's license notice requires Cover Texts, you must enclose the -copies in covers that carry, clearly and legibly, all these Cover -Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on -the back cover. Both covers must also clearly and legibly identify -you as the publisher of these copies. The front cover must present -the full title with all words of the title equally prominent and -visible. You may add other material on the covers in addition. -Copying with changes limited to the covers, as long as they preserve -the title of the Document and satisfy these conditions, can be treated -as verbatim copying in other respects. - -If the required texts for either cover are too voluminous to fit -legibly, you should put the first ones listed (as many as fit -reasonably) on the actual cover, and continue the rest onto adjacent -pages. - -If you publish or distribute Opaque copies of the Document numbering -more than 100, you must either include a machine-readable Transparent -copy along with each Opaque copy, or state in or with each Opaque copy -a computer-network location from which the general network-using -public has access to download using public-standard network protocols -a complete Transparent copy of the Document, free of added material. -If you use the latter option, you must take reasonably prudent steps, -when you begin distribution of Opaque copies in quantity, to ensure -that this Transparent copy will remain thus accessible at the stated -location until at least one year after the last time you distribute an -Opaque copy (directly or through your agents or retailers) of that -edition to the public. - -It is requested, but not required, that you contact the authors of the -Document well before redistributing any large number of copies, to give -them a chance to provide you with an updated version of the Document. - - -4. MODIFICATIONS - -You may copy and distribute a Modified Version of the Document under -the conditions of sections 2 and 3 above, provided that you release -the Modified Version under precisely this License, with the Modified -Version filling the role of the Document, thus licensing distribution -and modification of the Modified Version to whoever possesses a copy -of it. In addition, you must do these things in the Modified Version: - -A. Use in the Title Page (and on the covers, if any) a title distinct - from that of the Document, and from those of previous versions - (which should, if there were any, be listed in the History section - of the Document). You may use the same title as a previous version - if the original publisher of that version gives permission. -B. List on the Title Page, as authors, one or more persons or entities - responsible for authorship of the modifications in the Modified - Version, together with at least five of the principal authors of the - Document (all of its principal authors, if it has fewer than five), - unless they release you from this requirement. -C. State on the Title page the name of the publisher of the - Modified Version, as the publisher. -D. Preserve all the copyright notices of the Document. -E. Add an appropriate copyright notice for your modifications - adjacent to the other copyright notices. -F. Include, immediately after the copyright notices, a license notice - giving the public permission to use the Modified Version under the - terms of this License, in the form shown in the Addendum below. -G. Preserve in that license notice the full lists of Invariant Sections - and required Cover Texts given in the Document's license notice. -H. Include an unaltered copy of this License. -I. Preserve the section Entitled "History", Preserve its Title, and add - to it an item stating at least the title, year, new authors, and - publisher of the Modified Version as given on the Title Page. If - there is no section Entitled "History" in the Document, create one - stating the title, year, authors, and publisher of the Document as - given on its Title Page, then add an item describing the Modified - Version as stated in the previous sentence. -J. Preserve the network location, if any, given in the Document for - public access to a Transparent copy of the Document, and likewise - the network locations given in the Document for previous versions - it was based on. These may be placed in the "History" section. - You may omit a network location for a work that was published at - least four years before the Document itself, or if the original - publisher of the version it refers to gives permission. -K. For any section Entitled "Acknowledgements" or "Dedications", - Preserve the Title of the section, and preserve in the section all - the substance and tone of each of the contributor acknowledgements - and/or dedications given therein. -L. Preserve all the Invariant Sections of the Document, - unaltered in their text and in their titles. Section numbers - or the equivalent are not considered part of the section titles. -M. Delete any section Entitled "Endorsements". Such a section - may not be included in the Modified Version. -N. Do not retitle any existing section to be Entitled "Endorsements" - or to conflict in title with any Invariant Section. -O. Preserve any Warranty Disclaimers. - -If the Modified Version includes new front-matter sections or -appendices that qualify as Secondary Sections and contain no material -copied from the Document, you may at your option designate some or all -of these sections as invariant. To do this, add their titles to the -list of Invariant Sections in the Modified Version's license notice. -These titles must be distinct from any other section titles. - -You may add a section Entitled "Endorsements", provided it contains -nothing but endorsements of your Modified Version by various -parties--for example, statements of peer review or that the text has -been approved by an organization as the authoritative definition of a -standard. - -You may add a passage of up to five words as a Front-Cover Text, and a -passage of up to 25 words as a Back-Cover Text, to the end of the list -of Cover Texts in the Modified Version. Only one passage of -Front-Cover Text and one of Back-Cover Text may be added by (or -through arrangements made by) any one entity. If the Document already -includes a cover text for the same cover, previously added by you or -by arrangement made by the same entity you are acting on behalf of, -you may not add another; but you may replace the old one, on explicit -permission from the previous publisher that added the old one. - -The author(s) and publisher(s) of the Document do not by this License -give permission to use their names for publicity for or to assert or -imply endorsement of any Modified Version. - - -5. COMBINING DOCUMENTS - -You may combine the Document with other documents released under this -License, under the terms defined in section 4 above for modified -versions, provided that you include in the combination all of the -Invariant Sections of all of the original documents, unmodified, and -list them all as Invariant Sections of your combined work in its -license notice, and that you preserve all their Warranty Disclaimers. - -The combined work need only contain one copy of this License, and -multiple identical Invariant Sections may be replaced with a single -copy. If there are multiple Invariant Sections with the same name but -different contents, make the title of each such section unique by -adding at the end of it, in parentheses, the name of the original -author or publisher of that section if known, or else a unique number. -Make the same adjustment to the section titles in the list of -Invariant Sections in the license notice of the combined work. - -In the combination, you must combine any sections Entitled "History" -in the various original documents, forming one section Entitled -"History"; likewise combine any sections Entitled "Acknowledgements", -and any sections Entitled "Dedications". You must delete all sections -Entitled "Endorsements". - - -6. COLLECTIONS OF DOCUMENTS - -You may make a collection consisting of the Document and other documents -released under this License, and replace the individual copies of this -License in the various documents with a single copy that is included in -the collection, provided that you follow the rules of this License for -verbatim copying of each of the documents in all other respects. - -You may extract a single document from such a collection, and distribute -it individually under this License, provided you insert a copy of this -License into the extracted document, and follow this License in all -other respects regarding verbatim copying of that document. - - -7. AGGREGATION WITH INDEPENDENT WORKS - -A compilation of the Document or its derivatives with other separate -and independent documents or works, in or on a volume of a storage or -distribution medium, is called an "aggregate" if the copyright -resulting from the compilation is not used to limit the legal rights -of the compilation's users beyond what the individual works permit. -When the Document is included in an aggregate, this License does not -apply to the other works in the aggregate which are not themselves -derivative works of the Document. - -If the Cover Text requirement of section 3 is applicable to these -copies of the Document, then if the Document is less than one half of -the entire aggregate, the Document's Cover Texts may be placed on -covers that bracket the Document within the aggregate, or the -electronic equivalent of covers if the Document is in electronic form. -Otherwise they must appear on printed covers that bracket the whole -aggregate. - - -8. TRANSLATION - -Translation is considered a kind of modification, so you may -distribute translations of the Document under the terms of section 4. -Replacing Invariant Sections with translations requires special -permission from their copyright holders, but you may include -translations of some or all Invariant Sections in addition to the -original versions of these Invariant Sections. You may include a -translation of this License, and all the license notices in the -Document, and any Warranty Disclaimers, provided that you also include -the original English version of this License and the original versions -of those notices and disclaimers. In case of a disagreement between -the translation and the original version of this License or a notice -or disclaimer, the original version will prevail. - -If a section in the Document is Entitled "Acknowledgements", -"Dedications", or "History", the requirement (section 4) to Preserve -its Title (section 1) will typically require changing the actual -title. - - -9. TERMINATION - -You may not copy, modify, sublicense, or distribute the Document except -as expressly provided for under this License. Any other attempt to -copy, modify, sublicense or distribute the Document is void, and will -automatically terminate your rights under this License. However, -parties who have received copies, or rights, from you under this -License will not have their licenses terminated so long as such -parties remain in full compliance. - - -10. FUTURE REVISIONS OF THIS LICENSE - -The Free Software Foundation may publish new, revised versions -of the GNU Free Documentation License from time to time. Such new -versions will be similar in spirit to the present version, but may -differ in detail to address new problems or concerns. See -http://www.gnu.org/copyleft/. - -Each version of the License is given a distinguishing version number. -If the Document specifies that a particular numbered version of this -License "or any later version" applies to it, you have the option of -following the terms and conditions either of that specified version or -of any later version that has been published (not as a draft) by the -Free Software Foundation. If the Document does not specify a version -number of this License, you may choose any version ever published (not -as a draft) by the Free Software Foundation. - - -ADDENDUM: How to use this License for your documents - -To use this License in a document you have written, include a copy of -the License in the document and put the following copyright and -license notices just after the title page: - - Copyright (c) YEAR YOUR NAME. - Permission is granted to copy, distribute and/or modify this document - under the terms of the GNU Free Documentation License, Version 1.2 - or any later version published by the Free Software Foundation; - with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. - A copy of the license is included in the section entitled "GNU - Free Documentation License". - -If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts, -replace the "with...Texts." line with this: - - with the Invariant Sections being LIST THEIR TITLES, with the - Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST. - -If you have Invariant Sections without Cover Texts, or some other -combination of the three, merge those two alternatives to suit the -situation. - -If your document contains nontrivial examples of program code, we -recommend releasing these examples in parallel under your choice of -free software license, such as the GNU General Public License, -to permit their use in free software. diff --git a/pgpkey.asc b/pgpkey.asc deleted file mode 100644 index bd75349..0000000 --- a/pgpkey.asc +++ /dev/null @@ -1,40 +0,0 @@ ------BEGIN PGP PUBLIC KEY BLOCK----- -Version: GnuPG v1.4.1 (GNU/Linux) - -mQGiBD0kfGQRBADaGggoSHTZ8P17j92IMMxWPpML0TdvbhzW5iFF7a5th0xCn9od -pHVwc2YxuEulwDz0LJUx2IwwbttftHcJafcH51vk57Qq2+hvNAE1o9a/MWReMIwv -KfBi3Q1bVxWIjVPDbHd+ZUbbo0pozbfrHEaRPQ0qR+/ZgK5+V6WJiLElrwCgsCQy -FGfo72h5p46w7MrW4qSmalkD/RMcVmPkszF5J0N9pWlgcJ/fTYlMKIit3V/W/fru -L4KkUT3d9CMcJSBZrcVlXlDbPeBF8L7vl46NImd4xfnRKLwOuAy67Tld6CbC+UWz -rv6472rGetTTaj7iBH5nR62BQUmaLK6W6Q8vFOrqIBqXEz5iJ+RLYpIxH5M8gOz5 -7b7GBACIZaPaMVzIbTqnysDCgKEQqOyFbpgcGfSH52xH3XXeNrJhuenJFvBbeV8J -RgmKSnn1ZixFHJ261uGu5kOA1CQemNrTgZRaeHDu6mdZALdbxpLXp9DeOC/oTUWa -1O2xmAWcZZo+63s0MciC9zDrRjlNuGcVOiHZZLh9P9vEfoJos7Qu5L6d55Gq6LKT -IChpbWFjYXQpIDxpbWFjYXRAbWFpbC5pbWFjYXQuaWR2LnR3PoheBBMRAgAeBQJC -iLwmAhsDBgsJCAcDAgMVAgMDFgIBAh4BAheAAAoJEIvYLm8wuUtcmnYAnRQCNXWc -vgtk4CiTTBWqGWWZRjViAKCn/F6maM9R5RzuC1L5ER27f0AjbrkEDQQ9JHzZEBAA -owxPPj1TOZKGuav0eKopd8RrwFQ51P0FY85WyTAsCWg/KGcJIXFKwJ/r4U381iQd -z+16+E6oOzTIs/iwnkSKmfWx2M46uXdIa/VkLChZzHpCVDHeVICGE5sbECNS2gYD -CRx/Jl/FnXNaeaI0RZm3i4gf204bvqsPm+epI/BOW4cZmbkqSd4BuG2/i7y/BZzP -NhVseNVe2qhWFxs4Hj5S6y6xYSuuPLC4mZrkA7x1J9tq+wUt6z0mwIdRhEaK5iE5 -PB44XiwGKW02sLt5CQXDW/DbqXlyu6VP90iVjWLg0ftI28dULipw2n6u0DIGIxfL -i4dDf0gcYyqDF++aMWYTlB7a89Vt055dp7NC59VaqltW9DgKnxkiTUMxZ3HtqA67 -rwKtwKY3CQyuIYil31AQy0izi4fIu6MRznLtwHAfaqsB0Nej+kFl1XSUspe3P6ea -YzMs7on0X0KvPDWPo7AMz0Y/ex/XzYwR2+IzijTnaakH5TS7da0LKXb3FTV/PuIR -UgH3P/yOwRyOU4VLWqcyLxBJuMlX1WVz3UdNfHwRfm+jqPktP0qnQ9ZrFk3VEOGv -0hMvCeqj3Vw5CziYCTm3YiDG4OLPpUN3ByF944cUCYKwoGYEUKUf0vXPvUYdshqB -D49RyI0oy2nZstSt+iVefuCyWBYEyqIDu0eRGWY8FRMAAwUQAI/jMOnq6mP7mfbs -qq1ugXtx0r7cKNge0ebB/TA37ZLCo2UTdoxk/AsuGx1MK6kKJh3Zkxz89jb84CXA -jZbYbLOGhFioHCyiqfJwFbR7Abhsoo1NuEAtibJpFUm0oHym/Tjc4Xwht7cf52+8 -USfC918mFzmbPDOuIpkcHjGzXFztgDiMlX7iDrMvX2QOLzhp+g/I/pyAhAcKH8Eo -vcKeYOoQIM7hpP0eTZxgCDdRw9SpodU0/rTL6UzA4iXMcqncspH0OjfT5gxj3cOo -ofhaPxsIoqllZA/V/x7CeykdNE5L5SYv3c0NBnTMe9kV4K8V0JHTyz7N3ipiWJHP -VObvgdrJyA9YYCpgorfE7a1rtmLPfr5evrTuKP+VMEInqvA0mAxzX/HsbtsA+bNn -g6c5WibjO/kDKgfZfHFrPlLPiSSBVn9ygEySdlBuXpb5c7wft/YV0FyVAikbhY3l -3jJYmQ7kBxrtoIH9jK6Ff8rw7qbyBg6fDPoC3gevNdmoVtk5vTcKQTxPKlCeXTtE -JYfKDvX0BDkV8Wdizit03Sp0StpeietlX5vYQDyefp+w5J3k2SrbkEczzGZzXHq/ -5pm36cC0N0rA8ZW7JOpkThjZIJ733Y5DwtzhWqdUubWiCMmC7HfGmpI0OdV6QF8p -kCKXIsJ90Uiep0lEDNQZg4Y96kuUiEYEGBECAAYFAj0kfNoACgkQi9gubzC5S1xO -uACdELzJCBgMJVZ9siHwn48X2rXdQnIAn0yagIZfaIS0CfCamwcYeMfKcQQV -=GeL3 ------END PGP PUBLIC KEY BLOCK----- diff --git a/t/00-signature.t b/t/00-signature.t index 1cf917c..50a7346 100755 --- a/t/00-signature.t +++ b/t/00-signature.t @@ -1,17 +1,23 @@ #!/usr/bin/perl + use strict; print "1..1\n"; -if (!-s 'SIGNATURE') { +if (!$ENV{TEST_SIGNATURE}) { + print "ok 1 # skip Set the environment variable", + " TEST_SIGNATURE to enable this test\n"; +} +elsif (!-s 'SIGNATURE') { print "ok 1 # skip No signature file found\n"; } elsif (!eval { require Module::Signature; 1 }) { print "ok 1 # skip ", - "Next time around, consider install Module::Signature, ", - "so you can verify the integrity of this distribution.\n"; + "Next time around, consider install Module::Signature, ", + "so you can verify the integrity of this distribution.\n"; } -elsif (!eval { require Socket; Socket::inet_aton('pgp.mit.edu') }) { - print "ok 1 # skip Cannot connect to the keyserver\n"; +elsif (!eval { require Socket; Socket::inet_aton('pool.sks-keyservers.net') }) { + print "ok 1 # skip ", + "Cannot connect to the keyserver\n"; } else { (Module::Signature::verify() == Module::Signature::SIGNATURE_OK()) diff --git a/t/01-exhaust.t b/t/01-exhaust.t index d866b64..0bc063e 100755 --- a/t/01-exhaust.t +++ b/t/01-exhaust.t @@ -1,20 +1,19 @@ #! /usr/bin/perl -w # Test all the possible combination of options -# Copyright (c) 2007 imacat -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . +# Copyright (c) 2007-2021 imacat. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. use 5.005; use strict; @@ -30,7 +29,7 @@ use File::Spec::Functions qw(catdir catfile updir); use FindBin; use lib $FindBin::Bin; use _helper; -use vars qw($WORKDIR $arclog $tno); +our ($WORKDIR, $arclog, $tno); $WORKDIR = catdir($FindBin::Bin, "logs"); $arclog = catfile($FindBin::Bin, updir, "blib", "script", "arclog"); @@ -38,105 +37,105 @@ $tno = 0; # 1-2160: All possible option combinations # Test each log file format -foreach my $fmt (@LOGFMTS) { +foreach my $fmt (@LOG_FORMATS) { # Test each source log file type - foreach my $st (@SRCTYPES) { + foreach my $st (@SOURCE_TYPES) { # Test each result file type - foreach my $rt (@RESTYPES) { - # Test each keep type - foreach my $kt (@KEEPTYPES) { - # Test each override type - foreach my $ot (@OVERTYPES) { + foreach my $rt (@RESULT_TYPES) { + # Test each keep mode + foreach my $keep (@KEEP_MODES) { + # Test each override mode + foreach my $override (@OVERRIDE_MODES) { $_ = eval { return if $$st{"skip"} || $$rt{"skip"}; - my ($title, $cmd, $retno, $out, $err, $vardump, $logfile); + my ($title, $cmd, $ret_no, $out, $err, $var_dump, $logfile); my ($fr, $frb, @fle, $fle, $flr, %cef, %crf, %tef, %trf); my ($fs, $cs, %cem, @mle, $mt, %cof); rmtree $WORKDIR; mkpath $WORKDIR; $title = join ", ", ($$fmt{"title"}, $$st{"title"}, - $$rt{"title"}, $$kt{"title"}, $$ot{"title"}); - $logfile = randword; + $$rt{"title"}, $$keep{"title"}, $$override{"title"}); + $logfile = random_word; $fs = catfile($WORKDIR, $logfile . $$st{"suf"}); - ($cs, $vardump, %cem) = &{$$fmt{"sub"}}($fs); - frwrite(catfile($WORKDIR, "$logfile.vardump"), $vardump); + ($cs, $var_dump, %cem) = &{$$fmt{"sub"}}($fs); + write_raw_file(catfile($WORKDIR, "$logfile.var-dump"), $var_dump); @mle = sort keys %cem; - $mt = pop @mle if $$kt{"tm"}; - if ($$ot{"mkex"}) { - %cof = mkrndlog_existing $$fmt{"sub"}, + $mt = pop @mle if $$keep{"tm"}; + if ($$override{"exists"}) { + %cof = make_log_file $$fmt{"sub"}, $WORKDIR, "$logfile.%s" . $$rt{"suf"}, @mle; } else { %cof = map { "$logfile.$_" . $$rt{"suf"} => "" } @mle; } @fle = qw(); - push @fle, basename($fs) if !$$kt{"del"}; - push @fle, "$logfile.vardump"; - if ($$ot{"ok"}) { + push @fle, basename($fs) if !$$keep{"del"}; + push @fle, "$logfile.var-dump"; + if ($$override{"ok"}) { push @fle, map "$logfile.$_" . $$rt{"suf"}, @mle; } else { - push @fle, "$logfile.tmp-arclog" if $$kt{"tmp"}; + push @fle, "$logfile.tmp-arclog" if $$keep{"tmp"}; push @fle, grep $cof{$_} ne "", keys %cof; } - prsrvsrc $WORKDIR; - if (!$$kt{"stdin"}) { - @_ = ($arclog, qw(-d -d -d), @{$$kt{"opts"}}, - @{$$ot{"opts"}}, @{$$rt{"opts"}}, $fs); + preserve_source $WORKDIR; + if (!$$keep{"stdin"}) { + @_ = ($arclog, qw(-d -d -d), @{$$keep{"opts"}}, + @{$$override{"opts"}}, @{$$rt{"opts"}}, $fs); $cmd = join " ", @_; - ($retno, $out, $err) = runcmd "", @_; + ($ret_no, $out, $err) = run_cmd "", @_; } else { - @_ = ($arclog, qw(-d -d -d), @{$$kt{"opts"}}, - @{$$ot{"opts"}}, @{$$rt{"opts"}}, "-", + @_ = ($arclog, qw(-d -d -d), @{$$keep{"opts"}}, + @{$$override{"opts"}}, @{$$rt{"opts"}}, "-", catfile($WORKDIR, $logfile)); $cmd = join(" ", @_) . " < " . $fs; - ($retno, $out, $err) = runcmd frread $fs, @_; + ($ret_no, $out, $err) = run_cmd read_raw_file $fs, @_; } - ($fle, $flr) = (join(" ", sort @fle), flist $WORKDIR); + ($fle, $flr) = (join(" ", sort @fle), list_files $WORKDIR); %cef = qw(); # Expected content by file %tef = qw(); # Expected file type by file %crf = qw(); # Resulted content by file %trf = qw(); # Resulted file type by file - if (!$$kt{"del"}) { + if (!$$keep{"del"}) { $fr = $fs; $frb = basename($fr); - $cef{$frb} = !$$kt{"tmp"}? $cs: - !$$ot{"ok"}? "": - $$kt{"tm"}? $cem{$mt}: ""; + $cef{$frb} = !$$keep{"tmp"}? $cs: + !$$override{"ok"}? "": + $$keep{"tm"}? $cem{$mt}: ""; $tef{$frb} = $$st{"type"}; - ($crf{$frb}, $trf{$frb}) = (fread $fr, ftype $fr); + ($crf{$frb}, $trf{$frb}) = (read_file $fr, file_type $fr); } - if (!$$ot{"ok"} && $$kt{"tmp"}) { + if (!$$override{"ok"} && $$keep{"tmp"}) { $frb = "$logfile.tmp-arclog"; $fr = catfile($WORKDIR, $frb); - ($cef{$frb}, $tef{$frb}) = ($cs, TYPE_PLAIN); - ($crf{$frb}, $trf{$frb}) = (fread $fr, ftype $fr); + ($cef{$frb}, $tef{$frb}) = ($cs, TYPE_TEXT); + ($crf{$frb}, $trf{$frb}) = (read_file $fr, file_type $fr); } - $frb = "$logfile.vardump"; + $frb = "$logfile.var-dump"; $fr = catfile($WORKDIR, $frb); - ($cef{$frb}, $tef{$frb}) = ($vardump, TYPE_PLAIN); - ($crf{$frb}, $trf{$frb}) = (fread $fr, ftype $fr); + ($cef{$frb}, $tef{$frb}) = ($var_dump, TYPE_TEXT); + ($crf{$frb}, $trf{$frb}) = (read_file $fr, file_type $fr); foreach my $m (@mle) { $frb = "$logfile.$m" . $$rt{"suf"}; $fr = catfile($WORKDIR, $frb); - $cef{$frb} = &{$$ot{"ce"}}($cof{$frb}, $cem{$m}); + $cef{$frb} = &{$$override{"ce"}}($cof{$frb}, $cem{$m}); $tef{$frb} = $$rt{"type"}; - ($crf{$frb}, $trf{$frb}) = (fread $fr, ftype $fr); + ($crf{$frb}, $trf{$frb}) = (read_file $fr, file_type $fr); } die "$title\n$cmd\n$out$err" - unless $$ot{"ok"}? $retno == 0: $retno != 0; - die "$title\n$cmd\nresult files incorrect.\nGot: $flr\nExpected: $fle\nVariables: $vardump\nOutput:\n$out$err" + unless $$override{"ok"}? $ret_no == 0: $ret_no != 0; + die "$title\n$cmd\nresult files incorrect.\nGot: $flr\nExpected: $fle\nVariables: $var_dump\nOutput:\n$out$err" unless $flr eq $fle; foreach $fr (@fle) { - die "$title\n$cmd\n$fr: result type incorrect.\nGot: $trf{$fr}\nExpected: $tef{$fr}\nVariables: $vardump\nOutput:\n$out$err" - unless nofile || $trf{$fr} eq $tef{$fr} + die "$title\n$cmd\n$fr: result type incorrect.\nGot: $trf{$fr}\nExpected: $tef{$fr}\nVariables: $var_dump\nOutput:\n$out$err" + unless has_no_file || $trf{$fr} eq $tef{$fr} || ($tef{$fr} eq TYPE_BZIP2 && -z catfile($WORKDIR, $fr)); - die "$title\n$cmd\n$fr: result incorrect.\nGot:\n$crf{$fr}\nExpected:\n$cef{$fr}\nVariables: $vardump\nOutput:\n$out$err" + die "$title\n$cmd\n$fr: result incorrect.\nGot:\n$crf{$fr}\nExpected:\n$cef{$fr}\nVariables: $var_dump\nOutput:\n$out$err" unless $crf{$fr} eq $cef{$fr}; } 1; }; skip($$st{"skip"} || $$rt{"skip"}, $_, 1, $@); - cleanup $_ || $$st{"skip"} || $$rt{"skip"}, $WORKDIR, ++$tno; + clean_up $_ || $$st{"skip"} || $$rt{"skip"}, $WORKDIR, ++$tno; die unless $_ || $$st{"skip"} || $$rt{"skip"}; } } diff --git a/t/02-several.t b/t/02-several.t index 317db03..5042517 100755 --- a/t/02-several.t +++ b/t/02-several.t @@ -1,20 +1,19 @@ #! /usr/bin/perl -w # Test archiving several log files at once -# Copyright (c) 2007 imacat -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . +# Copyright (c) 2007-2021 imacat. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. use 5.005; use strict; @@ -30,87 +29,87 @@ use File::Spec::Functions qw(catdir catfile updir); use FindBin; use lib $FindBin::Bin; use _helper; -use vars qw($WORKDIR $arclog $tno); +our ($WORKDIR, $arclog, $tno); $WORKDIR = catdir($FindBin::Bin, "logs"); $arclog = catfile($FindBin::Bin, updir, "blib", "script", "arclog"); $tno = 0; # 1-16: Archiving several log files at once -foreach my $rt (@RESTYPES) { +foreach my $rt (@RESULT_TYPES) { my $skip; $skip = 0; # 1: Source log files listed as the arguments $_ = eval { - if ( ($$rt{"type"} eq TYPE_GZIP && nogzip) - || ($$rt{"type"} eq TYPE_BZIP2 && nobzip2)) { + if ( ($$rt{"type"} eq TYPE_GZIP && has_no_gzip) + || ($$rt{"type"} eq TYPE_BZIP2 && has_no_bzip2)) { $skip = 1; return; } - my ($title, $cmd, $retno, $out, $err, @vardump, %logfiles); + my ($title, $cmd, $ret_no, $out, $err, @var_dump, %logfiles); my ($fr, $frb, @fle, $fle, $flr, %cef, %crf, %tef, %trf); my ($num, @fs, @cs, @cem, @mle, %cof, $opref, $oprfb, $mt); my (@st, $fmt); rmtree $WORKDIR; mkpath $WORKDIR; - $fmt = $LOGFMTS[int rand @LOGFMTS]; + $fmt = $LOG_FORMATS[int rand @LOG_FORMATS]; $title = join ", ", "several log files", "all listed as arguments", $$fmt{"title"}, $$rt{"title"}; # (2-4 times available compression) log files - $_ = 2 + (nogzip? 0: 2) + (nobzip2? 0: 2); + $_ = 2 + (has_no_gzip? 0: 2) + (has_no_bzip2? 0: 2); $num = $_ + int rand $_; - %_ = qw(); + my %types = qw(); # At least 2 files for each available compression - foreach my $st (@SRCTYPES) { - next if ($$st{"type"} eq TYPE_GZIP && nogzip) - || ($$st{"type"} eq TYPE_BZIP2 && nobzip2); - @_ = grep !exists $_{$_}, (0...$num-1); - $_{$_[int rand @_]} = $st; - @_ = grep !exists $_{$_}, (0...$num-1); - $_{$_[int rand @_]} = $st; + foreach my $st (@SOURCE_TYPES) { + next if ($$st{"type"} eq TYPE_GZIP && has_no_gzip) + || ($$st{"type"} eq TYPE_BZIP2 && has_no_bzip2); + @_ = grep !exists $types{$_}, (0...$num-1); + $types{$_[int rand @_]} = $st; + @_ = grep !exists $types{$_}, (0...$num-1); + $types{$_[int rand @_]} = $st; } # Set random compression on the rest files - foreach (grep !exists $_{$_}, (0...$num-1)) { + foreach (grep !exists $types{$_}, (0...$num-1)) { do { - $_{$_} = $SRCTYPES[int rand @SRCTYPES]; - } until !(${$_{$_}}{"type"} eq TYPE_GZIP && nogzip) - && !(${$_{$_}}{"type"} eq TYPE_BZIP2 && nobzip2); + $types{$_} = $SOURCE_TYPES[int rand @SOURCE_TYPES]; + } until !(${$types{$_}}{"type"} eq TYPE_GZIP && has_no_gzip) + && !(${$types{$_}}{"type"} eq TYPE_BZIP2 && has_no_bzip2); } - @st = map $_{$_}, (0...$num-1); + @st = map $types{$_}, (0...$num-1); @fs = qw(); @cs = qw(); @cem = qw(); - @vardump = qw(); + @var_dump = qw(); @fle = qw(); %logfiles = qw(); for (my $k = 0; $k < $num; $k++) { - my ($logfile, $cs, $vardump); - do { $logfile = randword } until !exists $logfiles{$logfile}; + my ($logfile, $cs, $var_dump); + do { $logfile = random_word } until !exists $logfiles{$logfile}; $logfiles{$logfile} = 1; $logfile .= ${$st[$k]}{"suf"}; push @fs, catfile($WORKDIR, $logfile); - ($cs, $vardump, %_) = &{$$fmt{"sub"}}($fs[$k]); + ($cs, $var_dump, %types) = &{$$fmt{"sub"}}($fs[$k]); push @cs, $cs; - push @cem, {%_}; + push @cem, {%types}; push @fle, $logfile; - push @vardump, $vardump; - frwrite(catfile($WORKDIR, "$logfile.vardump"), $vardump); - push @fle, "$logfile.vardump"; + push @var_dump, $var_dump; + write_raw_file(catfile($WORKDIR, "$logfile.var-dump"), $var_dump); + push @fle, "$logfile.var-dump"; } - %_ = qw(); - %_ = (%_, map { $_ => 1 } keys %$_) foreach @cem; - @mle = sort keys %_; + %types = qw(); + %types = (%types, map { $_ => 1 } keys %$_) foreach @cem; + @mle = sort keys %types; $mt = pop @mle; - do { $oprfb = randword } until !exists $logfiles{$oprfb}; + do { $oprfb = random_word } until !exists $logfiles{$oprfb}; $opref = catfile($WORKDIR, $oprfb); - %cof = mkrndlog_existing $$fmt{"sub"}, + %cof = make_log_file $$fmt{"sub"}, $WORKDIR, "$oprfb.%s" . $$rt{"suf"}, @mle; push @fle, map "$oprfb.$_" . $$rt{"suf"}, @mle; - prsrvsrc $WORKDIR; + preserve_source $WORKDIR; @_ = ($arclog, qw(-d -d -d -o a), @{$$rt{"opts"}}, @fs, $opref); $cmd = join(" ", @_); - ($retno, $out, $err) = runcmd "", @_; - ($fle, $flr) = (join(" ", sort @fle), flist $WORKDIR); + ($ret_no, $out, $err) = run_cmd "", @_; + ($fle, $flr) = (join(" ", sort @fle), list_files $WORKDIR); %cef = qw(); # Expected content by file %tef = qw(); # Expected file type by file %crf = qw(); # Resulted content by file @@ -119,11 +118,11 @@ foreach my $rt (@RESTYPES) { $fr = $fs[$k]; $frb = basename($fr); ($cef{$frb}, $tef{$frb}) = (${$cem[$k]}{$mt}, ${$st[$k]}{"type"}); - ($crf{$frb}, $trf{$frb}) = (fread $fr, ftype $fr); - $fr = $fs[$k] . ".vardump"; + ($crf{$frb}, $trf{$frb}) = (read_file $fr, file_type $fr); + $fr = $fs[$k] . ".var-dump"; $frb = basename($fr); - ($cef{$frb}, $tef{$frb}) = ($vardump[$k], TYPE_PLAIN); - ($crf{$frb}, $trf{$frb}) = (fread $fr, ftype $fr); + ($cef{$frb}, $tef{$frb}) = ($var_dump[$k], TYPE_TEXT); + ($crf{$frb}, $trf{$frb}) = (read_file $fr, file_type $fr); } foreach my $m (@mle) { $fr = "$opref.$m" . $$rt{"suf"}; @@ -131,102 +130,102 @@ foreach my $rt (@RESTYPES) { $cef{$frb} = $cof{$frb} . join "", map(exists $$_{$m}? $$_{$m}: "", @cem); $tef{$frb} = $$rt{"type"}; - ($crf{$frb}, $trf{$frb}) = (fread $fr, ftype $fr); + ($crf{$frb}, $trf{$frb}) = (read_file $fr, file_type $fr); } - die "$title\n$cmd\n$out$err" unless $retno == 0; + die "$title\n$cmd\n$out$err" unless $ret_no == 0; die "$title\n$cmd\nresult files incorrect.\nGot: $flr\nExpected: $fle\nOutput:\n$out$err" unless $flr eq $fle; foreach $fr (@fle) { die "$title\n$cmd\n$fr: result type incorrect.\nGot: $trf{$fr}\nExpected: $tef{$fr}\nOutput:\n$out$err" - unless nofile || $trf{$fr} eq $tef{$fr}; + unless has_no_file || $trf{$fr} eq $tef{$fr}; die "$title\n$cmd\n$fr: result incorrect.\nGot:\n$crf{$fr}\nExpected:\n$cef{$fr}\nOutput:\n$out$err" unless $crf{$fr} eq $cef{$fr}; } 1; }; skip($skip, $_, 1, $@); - cleanup $_ || $skip, $WORKDIR, ++$tno; - + clean_up $_ || $skip, $WORKDIR, ++$tno; + # 2-4: One of the source log files is read from STDIN # The file type at STDIN - foreach my $ststdin (@SRCTYPES) { + foreach my $st_stdin (@SOURCE_TYPES) { $skip = 0; $_ = eval { - if ( ($$rt{"type"} eq TYPE_GZIP && nogzip) - || ($$rt{"type"} eq TYPE_BZIP2 && nobzip2) - || ($$ststdin{"type"} eq TYPE_GZIP && nogzip) - || ($$ststdin{"type"} eq TYPE_BZIP2 && nobzip2)) { + if ( ($$rt{"type"} eq TYPE_GZIP && has_no_gzip) + || ($$rt{"type"} eq TYPE_BZIP2 && has_no_bzip2) + || ($$st_stdin{"type"} eq TYPE_GZIP && has_no_gzip) + || ($$st_stdin{"type"} eq TYPE_BZIP2 && has_no_bzip2)) { $skip = 1; return; } - my ($title, $cmd, $retno, $out, $err, @vardump, %logfiles); + my ($title, $cmd, $ret_no, $out, $err, @var_dump, %logfiles); my ($fr, $frb, @fle, $fle, $flr, %cef, %crf, %tef, %trf); my ($num, @fs, @cs, @cem, @mle, %cof, $opref, $oprfb, $stdin); my (@st, $fmt); rmtree $WORKDIR; mkpath $WORKDIR; - $fmt = $LOGFMTS[int rand @LOGFMTS]; + $fmt = $LOG_FORMATS[int rand @LOG_FORMATS]; $title = join ", ", "several log files", "one read from STDIN", - "STDIN " . $$ststdin{"title"}, $$rt{"title"}; + "STDIN " . $$st_stdin{"title"}, $$rt{"title"}; # (2-4 times available compression) log files - $_ = 2 + (nogzip? 0: 2) + (nobzip2? 0: 2); + $_ = 2 + (has_no_gzip? 0: 2) + (has_no_bzip2? 0: 2); $num = $_ + int rand $_; - %_ = qw(); + my %types = qw(); # At least 2 files for each available compression - foreach my $st (@SRCTYPES) { - next if ($$st{"type"} eq TYPE_GZIP && nogzip) - || ($$st{"type"} eq TYPE_BZIP2 && nobzip2); - @_ = grep !exists $_{$_}, (0...$num-1); - $_{$_[int rand @_]} = $st; - @_ = grep !exists $_{$_}, (0...$num-1); - $_{$_[int rand @_]} = $st; + foreach my $st (@SOURCE_TYPES) { + next if ($$st{"type"} eq TYPE_GZIP && has_no_gzip) + || ($$st{"type"} eq TYPE_BZIP2 && has_no_bzip2); + @_ = grep !exists $types{$_}, (0...$num-1); + $types{$_[int rand @_]} = $st; + @_ = grep !exists $types{$_}, (0...$num-1); + $types{$_[int rand @_]} = $st; } # Set random compression on the rest files - foreach (grep !exists $_{$_}, (0...$num-1)) { + foreach (grep !exists $types{$_}, (0...$num-1)) { do { - $_{$_} = $SRCTYPES[int rand @SRCTYPES]; - } until !(${$_{$_}}{"type"} eq TYPE_GZIP && nogzip) - && !(${$_{$_}}{"type"} eq TYPE_BZIP2 && nobzip2); + $types{$_} = $SOURCE_TYPES[int rand @SOURCE_TYPES]; + } until !(${$types{$_}}{"type"} eq TYPE_GZIP && has_no_gzip) + && !(${$types{$_}}{"type"} eq TYPE_BZIP2 && has_no_bzip2); } # Choose the STDIN from the matching compression - @_ = grep ${$_{$_}}{"type"} eq $$ststdin{"type"}, (0...$num-1); + @_ = grep ${$types{$_}}{"type"} eq $$st_stdin{"type"}, (0...$num-1); $stdin = $_[int rand @_]; - @st = map $_{$_}, (0...$num-1); + @st = map $types{$_}, (0...$num-1); @fs = qw(); @cs = qw(); @cem = qw(); - @vardump = qw(); + @var_dump = qw(); @fle = qw(); %logfiles = qw(); for (my $k = 0; $k < $num; $k++) { - my ($logfile, $cs, $vardump); - do { $logfile = randword } until !exists $logfiles{$logfile}; + my ($logfile, $cs, $var_dump); + do { $logfile = random_word } until !exists $logfiles{$logfile}; $logfiles{$logfile} = 1; $logfile .= ${$st[$k]}{"suf"}; push @fs, catfile($WORKDIR, $logfile); - ($cs, $vardump, %_) = &{$$fmt{"sub"}}($fs[$k]); + ($cs, $var_dump, %types) = &{$$fmt{"sub"}}($fs[$k]); push @cs, $cs; - push @cem, {%_}; + push @cem, {%types}; push @fle, $logfile; - push @vardump, $vardump; - frwrite(catfile($WORKDIR, "$logfile.vardump"), $vardump); - push @fle, "$logfile.vardump"; + push @var_dump, $var_dump; + write_raw_file(catfile($WORKDIR, "$logfile.var-dump"), $var_dump); + push @fle, "$logfile.var-dump"; } - %_ = qw(); - %_ = (%_, map { $_ => 1 } keys %$_) foreach @cem; - @mle = sort keys %_; - do { $oprfb = randword } until !exists $logfiles{$oprfb}; + %types = qw(); + %types = (%types, map { $_ => 1 } keys %$_) foreach @cem; + @mle = sort keys %types; + do { $oprfb = random_word } until !exists $logfiles{$oprfb}; $opref = catfile($WORKDIR, $oprfb); - %cof = mkrndlog_existing $$fmt{"sub"}, + %cof = make_log_file $$fmt{"sub"}, $WORKDIR, "$oprfb.%s" . $$rt{"suf"}, @mle; push @fle, map "$oprfb.$_" . $$rt{"suf"}, @mle; - prsrvsrc $WORKDIR; + preserve_source $WORKDIR; @_ = @fs; $_[$stdin] = "-"; @_ = ($arclog, qw(-d -d -d -k a -o a), @{$$rt{"opts"}}, @_, $opref); $cmd = join(" ", @_) . " < " . $fs[$stdin]; - ($retno, $out, $err) = runcmd frread $fs[$stdin], @_; - ($fle, $flr) = (join(" ", sort @fle), flist $WORKDIR); + ($ret_no, $out, $err) = run_cmd read_raw_file $fs[$stdin], @_; + ($fle, $flr) = (join(" ", sort @fle), list_files $WORKDIR); %cef = qw(); # Expected content by file %tef = qw(); # Expected file type by file %crf = qw(); # Resulted content by file @@ -235,11 +234,11 @@ foreach my $rt (@RESTYPES) { $fr = $fs[$k]; $frb = basename($fr); ($cef{$frb}, $tef{$frb}) = ($cs[$k], ${$st[$k]}{"type"}); - ($crf{$frb}, $trf{$frb}) = (fread $fr, ftype $fr); - $fr = $fs[$k] . ".vardump"; + ($crf{$frb}, $trf{$frb}) = (read_file $fr, file_type $fr); + $fr = $fs[$k] . ".var-dump"; $frb = basename($fr); - ($cef{$frb}, $tef{$frb}) = ($vardump[$k], TYPE_PLAIN); - ($crf{$frb}, $trf{$frb}) = (fread $fr, ftype $fr); + ($cef{$frb}, $tef{$frb}) = ($var_dump[$k], TYPE_TEXT); + ($crf{$frb}, $trf{$frb}) = (read_file $fr, file_type $fr); } foreach my $m (@mle) { $fr = "$opref.$m" . $$rt{"suf"}; @@ -247,20 +246,20 @@ foreach my $rt (@RESTYPES) { $cef{$frb} = $cof{$frb} . join "", map(exists $$_{$m}? $$_{$m}: "", @cem); $tef{$frb} = $$rt{"type"}; - ($crf{$frb}, $trf{$frb}) = (fread $fr, ftype $fr); + ($crf{$frb}, $trf{$frb}) = (read_file $fr, file_type $fr); } - die "$title\n$cmd\n$out$err" unless $retno == 0; + die "$title\n$cmd\n$out$err" unless $ret_no == 0; die "$title\n$cmd\nresult files incorrect.\nGot: $flr\nExpected: $fle\nOutput:\n$out$err" unless $flr eq $fle; foreach $fr (@fle) { die "$title\n$cmd\n$fr: result type incorrect.\nGot: $trf{$fr}\nExpected: $tef{$fr}\nOutput:\n$out$err" - unless nofile || $trf{$fr} eq $tef{$fr}; + unless has_no_file || $trf{$fr} eq $tef{$fr}; die "$title\n$cmd\n$fr: result incorrect.\nGot:\n$crf{$fr}\nExpected:\n$cef{$fr}\nOutput:\n$out$err" unless $crf{$fr} eq $cef{$fr}; } 1; }; skip($skip, $_, 1, $@); - cleanup $_ || $skip, $WORKDIR, ++$tno; + clean_up $_ || $skip, $WORKDIR, ++$tno; } } diff --git a/t/03-fallback.t b/t/03-fallback.t index 07ddec3..cb8ff35 100755 --- a/t/03-fallback.t +++ b/t/03-fallback.t @@ -1,20 +1,19 @@ #! /usr/bin/perl -w # Test fallback behavior -# Copyright (c) 2007 imacat -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . +# Copyright (c) 2007-2021 imacat. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. use 5.005; use strict; @@ -30,87 +29,87 @@ use File::Spec::Functions qw(catdir catfile updir); use FindBin; use lib $FindBin::Bin; use _helper; -use vars qw($WORKDIR $arclog $tno); +our ($WORKDIR, $arclog, $tno); $WORKDIR = catdir($FindBin::Bin, "logs"); $arclog = catfile($FindBin::Bin, updir, "blib", "script", "arclog"); $tno = 0; # 1-4: STDIN keep fall back -foreach my $kt (@KEEPTYPES) { +foreach my $kt (@KEEP_MODES) { next if $$kt{"stdin"} || $$kt{"title"} eq "keep all"; $_ = eval { - my ($title, $cmd, $retno, $out, $err, @vardump, %logfiles); + my ($title, $cmd, $ret_no, $out, $err, @var_dump, %logfiles); my ($fr, $frb, @fle, $fle, $flr, %cef, %crf, %tef, %trf); my ($num, @fs, @cs, @cem, @mle, %cof, $opref, $oprfb, $stdin); my (@st, $fmt, $rt); rmtree $WORKDIR; mkpath $WORKDIR; - $fmt = $LOGFMTS[int rand @LOGFMTS]; + $fmt = $LOG_FORMATS[int rand @LOG_FORMATS]; # A random available compression do { - $rt = $RESTYPES[int rand @RESTYPES]; - } until !($$rt{"type"} eq TYPE_GZIP && nogzip) - && !($$rt{"type"} eq TYPE_BZIP2 && nobzip2); + $rt = $RESULT_TYPES[int rand @RESULT_TYPES]; + } until !($$rt{"type"} eq TYPE_GZIP && has_no_gzip) + && !($$rt{"type"} eq TYPE_BZIP2 && has_no_bzip2); $title = join ", ", "STDIN keep fall back", $$kt{"title"}, $$fmt{"title"}, $$rt{"title"}; # (2-4 times available compression) log files - $_ = 2 + (nogzip? 0: 2) + (nobzip2? 0: 2); + $_ = 2 + (has_no_gzip? 0: 2) + (has_no_bzip2? 0: 2); $num = $_ + int rand $_; $stdin = int rand $num; - %_ = qw(); + my %types = qw(); # At least 2 files for each available compression - foreach my $st (@SRCTYPES) { - next if ($$st{"type"} eq TYPE_GZIP && nogzip) - || ($$st{"type"} eq TYPE_BZIP2 && nobzip2); - @_ = grep !exists $_{$_}, (0...$num-1); - $_{$_[int rand @_]} = $st; - @_ = grep !exists $_{$_}, (0...$num-1); - $_{$_[int rand @_]} = $st; + foreach my $st (@SOURCE_TYPES) { + next if ($$st{"type"} eq TYPE_GZIP && has_no_gzip) + || ($$st{"type"} eq TYPE_BZIP2 && has_no_bzip2); + @_ = grep !exists $types{$_}, (0...$num-1); + $types{$_[int rand @_]} = $st; + @_ = grep !exists $types{$_}, (0...$num-1); + $types{$_[int rand @_]} = $st; } # Set random compression on the rest files - foreach (grep !exists $_{$_}, (0...$num-1)) { + foreach (grep !exists $types{$_}, (0...$num-1)) { do { - $_{$_} = $SRCTYPES[int rand @SRCTYPES]; - } until !(${$_{$_}}{"type"} eq TYPE_GZIP && nogzip) - && !(${$_{$_}}{"type"} eq TYPE_BZIP2 && nobzip2); + $types{$_} = $SOURCE_TYPES[int rand @SOURCE_TYPES]; + } until !(${$types{$_}}{"type"} eq TYPE_GZIP && has_no_gzip) + && !(${$types{$_}}{"type"} eq TYPE_BZIP2 && has_no_bzip2); } - @st = map $_{$_}, (0...$num-1); + @st = map $types{$_}, (0...$num-1); @fs = qw(); @cs = qw(); @cem = qw(); - @vardump = qw(); + @var_dump = qw(); @fle = qw(); %logfiles = qw(); for (my $k = 0; $k < $num; $k++) { - my ($logfile, $cs, $vardump); - do { $logfile = randword } until !exists $logfiles{$logfile}; + my ($logfile, $cs, $var_dump); + do { $logfile = random_word } until !exists $logfiles{$logfile}; $logfiles{$logfile} = 1; $logfile .= ${$st[$k]}{"suf"}; push @fs, catfile($WORKDIR, $logfile); - ($cs, $vardump, %_) = &{$$fmt{"sub"}}($fs[$k]); + ($cs, $var_dump, %types) = &{$$fmt{"sub"}}($fs[$k]); push @cs, $cs; - push @cem, {%_}; + push @cem, {%types}; push @fle, $logfile; - push @vardump, $vardump; - frwrite(catfile($WORKDIR, "$logfile.vardump"), $vardump); - push @fle, "$logfile.vardump"; + push @var_dump, $var_dump; + write_raw_file(catfile($WORKDIR, "$logfile.var-dump"), $var_dump); + push @fle, "$logfile.var-dump"; } - %_ = qw(); - %_ = (%_, map { $_ => 1 } keys %$_) foreach @cem; - @mle = sort keys %_; - do { $oprfb = randword } until !exists $logfiles{$oprfb}; + %types = qw(); + %types = (%types, map { $_ => 1 } keys %$_) foreach @cem; + @mle = sort keys %types; + do { $oprfb = random_word } until !exists $logfiles{$oprfb}; $opref = catfile($WORKDIR, $oprfb); - %cof = mkrndlog_existing $$fmt{"sub"}, + %cof = make_log_file $$fmt{"sub"}, $WORKDIR, "$oprfb.%s" . $$rt{"suf"}, @mle; push @fle, map "$oprfb.$_" . $$rt{"suf"}, @mle; - prsrvsrc $WORKDIR; + preserve_source $WORKDIR; @_ = @fs; $_[$stdin] = "-"; @_ = ($arclog, qw(-d -d -d -o a), @{$$kt{"opts"}}, @{$$rt{"opts"}}, @_, $opref); $cmd = join(" ", @_) . " < " . $fs[$stdin]; - ($retno, $out, $err) = runcmd frread $fs[$stdin], @_; - ($fle, $flr) = (join(" ", sort @fle), flist $WORKDIR); + ($ret_no, $out, $err) = run_cmd read_raw_file $fs[$stdin], @_; + ($fle, $flr) = (join(" ", sort @fle), list_files $WORKDIR); %cef = qw(); # Expected content by file %tef = qw(); # Expected file type by file %crf = qw(); # Resulted content by file @@ -119,11 +118,11 @@ foreach my $kt (@KEEPTYPES) { $fr = $fs[$k]; $frb = basename($fr); ($cef{$frb}, $tef{$frb}) = ($cs[$k], ${$st[$k]}{"type"}); - ($crf{$frb}, $trf{$frb}) = (fread $fr, ftype $fr); - $fr = $fs[$k] . ".vardump"; + ($crf{$frb}, $trf{$frb}) = (read_file $fr, file_type $fr); + $fr = $fs[$k] . ".var-dump"; $frb = basename($fr); - ($cef{$frb}, $tef{$frb}) = ($vardump[$k], TYPE_PLAIN); - ($crf{$frb}, $trf{$frb}) = (fread $fr, ftype $fr); + ($cef{$frb}, $tef{$frb}) = ($var_dump[$k], TYPE_TEXT); + ($crf{$frb}, $trf{$frb}) = (read_file $fr, file_type $fr); } foreach my $m (@mle) { $fr = "$opref.$m" . $$rt{"suf"}; @@ -131,96 +130,96 @@ foreach my $kt (@KEEPTYPES) { $cef{$frb} = $cof{$frb} . join "", map(exists $$_{$m}? $$_{$m}: "", @cem); $tef{$frb} = $$rt{"type"}; - ($crf{$frb}, $trf{$frb}) = (fread $fr, ftype $fr); + ($crf{$frb}, $trf{$frb}) = (read_file $fr, file_type $fr); } - die "$title\n$cmd\n$out$err" unless $retno == 0; + die "$title\n$cmd\n$out$err" unless $ret_no == 0; die "$title\n$cmd\nresult files incorrect.\nGot: $flr\nExpected: $fle\nOutput:\n$out$err" unless $flr eq $fle; foreach $fr (@fle) { die "$title\n$cmd\n$fr: result type incorrect.\nGot: $trf{$fr}\nExpected: $tef{$fr}\nOutput:\n$out$err" - unless nofile || $trf{$fr} eq $tef{$fr}; + unless has_no_file || $trf{$fr} eq $tef{$fr}; die "$title\n$cmd\n$fr: result incorrect.\nGot:\n$crf{$fr}\nExpected:\n$cef{$fr}\nOutput:\n$out$err" unless $crf{$fr} eq $cef{$fr}; } 1; }; ok($_, 1, $@); - cleanup $_, $WORKDIR, ++$tno; + clean_up $_, $WORKDIR, ++$tno; } # 5: STDIN override ask fall back $_ = eval { - my ($title, $cmd, $retno, $out, $err, @vardump, %logfiles); + my ($title, $cmd, $ret_no, $out, $err, @var_dump, %logfiles); my ($fr, $frb, @fle, $fle, $flr, %cef, %crf, %tef, %trf); my ($num, @fs, @cs, @cem, @mle, %cof, $opref, $oprfb, $stdin); my (@st, $fmt, $rt); rmtree $WORKDIR; mkpath $WORKDIR; - $fmt = $LOGFMTS[int rand @LOGFMTS]; + $fmt = $LOG_FORMATS[int rand @LOG_FORMATS]; # A random available compression do { - $rt = $RESTYPES[int rand @RESTYPES]; - } until !($$rt{"type"} eq TYPE_GZIP && nogzip) - && !($$rt{"type"} eq TYPE_BZIP2 && nobzip2); + $rt = $RESULT_TYPES[int rand @RESULT_TYPES]; + } until !($$rt{"type"} eq TYPE_GZIP && has_no_gzip) + && !($$rt{"type"} eq TYPE_BZIP2 && has_no_bzip2); $title = join ", ", "STDIN override ask fall back", $$fmt{"title"}, $$rt{"title"}; # (2-4 times available compression) log files - $_ = 2 + (nogzip? 0: 2) + (nobzip2? 0: 2); + $_ = 2 + (has_no_gzip? 0: 2) + (has_no_bzip2? 0: 2); $num = $_ + int rand $_; $stdin = int rand $num; - %_ = qw(); + my %types = qw(); # At least 2 files for each available compression - foreach my $st (@SRCTYPES) { - next if ($$st{"type"} eq TYPE_GZIP && nogzip) - || ($$st{"type"} eq TYPE_BZIP2 && nobzip2); - @_ = grep !exists $_{$_}, (0...$num-1); - $_{$_[int rand @_]} = $st; - @_ = grep !exists $_{$_}, (0...$num-1); - $_{$_[int rand @_]} = $st; + foreach my $st (@SOURCE_TYPES) { + next if ($$st{"type"} eq TYPE_GZIP && has_no_gzip) + || ($$st{"type"} eq TYPE_BZIP2 && has_no_bzip2); + @_ = grep !exists $types{$_}, (0...$num-1); + $types{$_[int rand @_]} = $st; + @_ = grep !exists $types{$_}, (0...$num-1); + $types{$_[int rand @_]} = $st; } # Set random compression on the rest files - foreach (grep !exists $_{$_}, (0...$num-1)) { + foreach (grep !exists $types{$_}, (0...$num-1)) { do { - $_{$_} = $SRCTYPES[int rand @SRCTYPES]; - } until !(${$_{$_}}{"type"} eq TYPE_GZIP && nogzip) - && !(${$_{$_}}{"type"} eq TYPE_BZIP2 && nobzip2); + $types{$_} = $SOURCE_TYPES[int rand @SOURCE_TYPES]; + } until !(${$types{$_}}{"type"} eq TYPE_GZIP && has_no_gzip) + && !(${$types{$_}}{"type"} eq TYPE_BZIP2 && has_no_bzip2); } - @st = map $_{$_}, (0...$num-1); + @st = map $types{$_}, (0...$num-1); @fs = qw(); @cs = qw(); @cem = qw(); - @vardump = qw(); + @var_dump = qw(); @fle = qw(); %logfiles = qw(); for (my $k = 0; $k < $num; $k++) { - my ($logfile, $cs, $vardump); - do { $logfile = randword } until !exists $logfiles{$logfile}; + my ($logfile, $cs, $var_dump); + do { $logfile = random_word } until !exists $logfiles{$logfile}; $logfiles{$logfile} = 1; $logfile .= ${$st[$k]}{"suf"}; push @fs, catfile($WORKDIR, $logfile); - ($cs, $vardump, %_) = &{$$fmt{"sub"}}($fs[$k]); + ($cs, $var_dump, %types) = &{$$fmt{"sub"}}($fs[$k]); push @cs, $cs; - push @cem, {%_}; + push @cem, {%types}; push @fle, $logfile; - push @vardump, $vardump; - frwrite(catfile($WORKDIR, "$logfile.vardump"), $vardump); - push @fle, "$logfile.vardump"; + push @var_dump, $var_dump; + write_raw_file(catfile($WORKDIR, "$logfile.var-dump"), $var_dump); + push @fle, "$logfile.var-dump"; } - %_ = qw(); - %_ = (%_, map { $_ => 1 } keys %$_) foreach @cem; - @mle = sort keys %_; - do { $oprfb = randword } until !exists $logfiles{$oprfb}; + %types = qw(); + %types = (%types, map { $_ => 1 } keys %$_) foreach @cem; + @mle = sort keys %types; + do { $oprfb = random_word } until !exists $logfiles{$oprfb}; $opref = catfile($WORKDIR, $oprfb); - %cof = mkrndlog_existing $$fmt{"sub"}, + %cof = make_log_file $$fmt{"sub"}, $WORKDIR, "$oprfb.%s" . $$rt{"suf"}, @mle; push @fle, grep $cof{$_} ne "", keys %cof; - prsrvsrc $WORKDIR; + preserve_source $WORKDIR; @_ = @fs; $_[$stdin] = "-"; @_ = ($arclog, qw(-d -d -d -o ask), @{$$rt{"opts"}}, @_, $opref); $cmd = join(" ", @_) . " < " . $fs[$stdin]; - ($retno, $out, $err) = runcmd frread $fs[$stdin], @_; - ($fle, $flr) = (join(" ", sort @fle), flist $WORKDIR); + ($ret_no, $out, $err) = run_cmd read_raw_file $fs[$stdin], @_; + ($fle, $flr) = (join(" ", sort @fle), list_files $WORKDIR); %cef = qw(); # Expected content by file %tef = qw(); # Expected file type by file %crf = qw(); # Resulted content by file @@ -229,28 +228,28 @@ $_ = eval { $fr = $fs[$k]; $frb = basename($fr); ($cef{$frb}, $tef{$frb}) = ($cs[$k], ${$st[$k]}{"type"}); - ($crf{$frb}, $trf{$frb}) = (fread $fr, ftype $fr); - $fr = $fs[$k] . ".vardump"; + ($crf{$frb}, $trf{$frb}) = (read_file $fr, file_type $fr); + $fr = $fs[$k] . ".var-dump"; $frb = basename($fr); - ($cef{$frb}, $tef{$frb}) = ($vardump[$k], TYPE_PLAIN); - ($crf{$frb}, $trf{$frb}) = (fread $fr, ftype $fr); + ($cef{$frb}, $tef{$frb}) = ($var_dump[$k], TYPE_TEXT); + ($crf{$frb}, $trf{$frb}) = (read_file $fr, file_type $fr); } foreach my $m (@mle) { $fr = "$opref.$m" . $$rt{"suf"}; $frb = basename($fr); ($cef{$frb}, $tef{$frb}) = ($cof{$frb}, $$rt{"type"}); - ($crf{$frb}, $trf{$frb}) = (fread $fr, ftype $fr); + ($crf{$frb}, $trf{$frb}) = (read_file $fr, file_type $fr); } - die "$title\n$cmd\n$out$err" unless $retno != 0; + die "$title\n$cmd\n$out$err" unless $ret_no != 0; die "$title\n$cmd\nresult files incorrect.\nGot: $flr\nExpected: $fle\nOutput:\n$out$err" unless $flr eq $fle; foreach $fr (@fle) { die "$title\n$cmd\n$fr: result type incorrect.\nGot: $trf{$fr}\nExpected: $tef{$fr}\nOutput:\n$out$err" - unless nofile || $trf{$fr} eq $tef{$fr}; + unless has_no_file || $trf{$fr} eq $tef{$fr}; die "$title\n$cmd\n$fr: result incorrect.\nGot:\n$crf{$fr}\nExpected:\n$cef{$fr}\nOutput:\n$out$err" unless $crf{$fr} eq $cef{$fr}; } 1; }; ok($_, 1, $@); -cleanup $_, $WORKDIR, ++$tno; +clean_up $_, $WORKDIR, ++$tno; diff --git a/t/04-errors.t b/t/04-errors.t index 88d2589..5c70f54 100755 --- a/t/04-errors.t +++ b/t/04-errors.t @@ -1,20 +1,19 @@ #! /usr/bin/perl -w # Test the errors that should be captured. -# Copyright (c) 2007 imacat -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . +# Copyright (c) 2007-2021 imacat. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. use 5.005; use strict; @@ -30,7 +29,7 @@ use File::Spec::Functions qw(catdir catfile updir); use FindBin; use lib $FindBin::Bin; use _helper; -use vars qw($WORKDIR $arclog $tno); +our ($WORKDIR, $arclog, $tno); $WORKDIR = catdir($FindBin::Bin, "logs"); $arclog = catfile($FindBin::Bin, updir, "blib", "script", "arclog"); @@ -38,166 +37,166 @@ $tno = 0; # 1: STDIN alone $_ = eval { - my ($title, $cmd, $retno, $out, $err, $vardump, $logfile); + my ($title, $cmd, $ret_no, $out, $err, $var_dump, $logfile); my ($fr, $frb, @fle, $fle, $flr, %cef, %crf, %tef, %trf); my ($fs, $cs, %cem); rmtree $WORKDIR; mkpath $WORKDIR; $title = "STDIN alone"; - $logfile = randword; + $logfile = random_word; $fs = catfile($WORKDIR, $logfile); - ($cs, $vardump, %cem) = mkrndlog_apache $fs; - frwrite(catfile($WORKDIR, "$logfile.vardump"), $vardump); + ($cs, $var_dump, %cem) = make_apache_log_file $fs; + write_raw_file(catfile($WORKDIR, "$logfile.var-dump"), $var_dump); @fle = qw(); push @fle, basename($fs); - push @fle, "$logfile.vardump"; - prsrvsrc $WORKDIR; + push @fle, "$logfile.var-dump"; + preserve_source $WORKDIR; @_ = ($arclog, qw(-d -d -d -c n), "-"); $cmd = join(" ", @_) . " < " . $fs; - ($retno, $out, $err) = runcmd frread $fs, @_; - ($fle, $flr) = (join(" ", sort @fle), flist $WORKDIR); + ($ret_no, $out, $err) = run_cmd read_raw_file $fs, @_; + ($fle, $flr) = (join(" ", sort @fle), list_files $WORKDIR); %cef = qw(); # Expected content by file %tef = qw(); # Expected file type by file %crf = qw(); # Resulted content by file %trf = qw(); # Resulted file type by file $fr = $fs; $frb = basename($fr); - ($cef{$frb}, $tef{$frb}) = ($cs, TYPE_PLAIN); - ($crf{$frb}, $trf{$frb}) = (fread $fr, ftype $fr); - $frb = "$logfile.vardump"; + ($cef{$frb}, $tef{$frb}) = ($cs, TYPE_TEXT); + ($crf{$frb}, $trf{$frb}) = (read_file $fr, file_type $fr); + $frb = "$logfile.var-dump"; $fr = catfile($WORKDIR, $frb); - ($cef{$frb}, $tef{$frb}) = ($vardump, TYPE_PLAIN); - ($crf{$frb}, $trf{$frb}) = (fread $fr, ftype $fr); - die "$title\n$cmd\n$out$err" unless $retno != 0; + ($cef{$frb}, $tef{$frb}) = ($var_dump, TYPE_TEXT); + ($crf{$frb}, $trf{$frb}) = (read_file $fr, file_type $fr); + die "$title\n$cmd\n$out$err" unless $ret_no != 0; die "$title\n$cmd\nresult files incorrect.\nGot: $flr\nExpected: $fle\nOutput:\n$out$err" unless $flr eq $fle; foreach $fr (@fle) { die "$title\n$cmd\n$fr: result type incorrect.\nGot: $trf{$fr}\nExpected: $tef{$fr}\nOutput:\n$out$err" - unless nofile || $trf{$fr} eq $tef{$fr}; + unless has_no_file || $trf{$fr} eq $tef{$fr}; die "$title\n$cmd\n$fr: result incorrect.\nGot:\n$crf{$fr}\nExpected:\n$cef{$fr}\nOutput:\n$out$err" unless $crf{$fr} eq $cef{$fr}; } 1; }; ok($_, 1, $@); -cleanup $_, $WORKDIR, ++$tno; +clean_up $_, $WORKDIR, ++$tno; # 2: STDOUT as output prefix $_ = eval { - my ($title, $cmd, $retno, $out, $err, $vardump, $logfile); + my ($title, $cmd, $ret_no, $out, $err, $var_dump, $logfile); my ($fr, $frb, @fle, $fle, $flr, %cef, %crf, %tef, %trf); my ($fs, $cs, %cem); rmtree $WORKDIR; mkpath $WORKDIR; $title = "STDOUT as output prefix"; - $logfile = randword; + $logfile = random_word; $fs = catfile($WORKDIR, $logfile); - ($cs, $vardump, %cem) = mkrndlog_apache $fs; - frwrite(catfile($WORKDIR, "$logfile.vardump"), $vardump); + ($cs, $var_dump, %cem) = make_apache_log_file $fs; + write_raw_file(catfile($WORKDIR, "$logfile.var-dump"), $var_dump); @fle = qw(); push @fle, basename($fs); - push @fle, "$logfile.vardump"; - prsrvsrc $WORKDIR; + push @fle, "$logfile.var-dump"; + preserve_source $WORKDIR; @_ = ($arclog, qw(-d -d -d -c n), $logfile, "-"); $cmd = join " ", @_; - ($retno, $out, $err) = runcmd "", @_; - ($fle, $flr) = (join(" ", sort @fle), flist $WORKDIR); + ($ret_no, $out, $err) = run_cmd "", @_; + ($fle, $flr) = (join(" ", sort @fle), list_files $WORKDIR); %cef = qw(); # Expected content by file %tef = qw(); # Expected file type by file %crf = qw(); # Resulted content by file %trf = qw(); # Resulted file type by file $fr = $fs; $frb = basename($fr); - ($cef{$frb}, $tef{$frb}) = ($cs, TYPE_PLAIN); - ($crf{$frb}, $trf{$frb}) = (fread $fr, ftype $fr); - $frb = "$logfile.vardump"; + ($cef{$frb}, $tef{$frb}) = ($cs, TYPE_TEXT); + ($crf{$frb}, $trf{$frb}) = (read_file $fr, file_type $fr); + $frb = "$logfile.var-dump"; $fr = catfile($WORKDIR, $frb); - ($cef{$frb}, $tef{$frb}) = ($vardump, TYPE_PLAIN); - ($crf{$frb}, $trf{$frb}) = (fread $fr, ftype $fr); - die "$title\n$cmd\n$out$err" unless $retno != 0; + ($cef{$frb}, $tef{$frb}) = ($var_dump, TYPE_TEXT); + ($crf{$frb}, $trf{$frb}) = (read_file $fr, file_type $fr); + die "$title\n$cmd\n$out$err" unless $ret_no != 0; die "$title\n$cmd\nresult files incorrect.\nGot: $flr\nExpected: $fle\nOutput:\n$out$err" unless $flr eq $fle; foreach $fr (@fle) { die "$title\n$cmd\n$fr: result type incorrect.\nGot: $trf{$fr}\nExpected: $tef{$fr}\nOutput:\n$out$err" - unless nofile || $trf{$fr} eq $tef{$fr}; + unless has_no_file || $trf{$fr} eq $tef{$fr}; die "$title\n$cmd\n$fr: result incorrect.\nGot:\n$crf{$fr}\nExpected:\n$cef{$fr}\nOutput:\n$out$err" unless $crf{$fr} eq $cef{$fr}; } 1; }; ok($_, 1, $@); -cleanup $_, $WORKDIR, ++$tno; +clean_up $_, $WORKDIR, ++$tno; # 3: A same log file is specified more than once $_ = eval { - my ($title, $cmd, $retno, $out, $err, @vardump, %logfiles); + my ($title, $cmd, $ret_no, $out, $err, @var_dump, %logfiles); my ($fr, $frb, @fle, $fle, $flr, %cef, %crf, %tef, %trf); my ($num, @fs, @cs, @cem, @mle, %cof, $opref, $oprfb, $mt); my (@st, $fmt, $rt, $dup); rmtree $WORKDIR; mkpath $WORKDIR; - $fmt = $LOGFMTS[int rand @LOGFMTS]; - $rt = $RESTYPES[int rand @RESTYPES]; + $fmt = $LOG_FORMATS[int rand @LOG_FORMATS]; + $rt = $RESULT_TYPES[int rand @RESULT_TYPES]; $title = join ",", "A same log file is specified more than once", $$fmt{"title"}, $$rt{"title"}; # (2-4 times available compression) log files - $_ = 2 + (nogzip? 0: 2) + (nobzip2? 0: 2); + $_ = 2 + (has_no_gzip? 0: 2) + (has_no_bzip2? 0: 2); $num = $_ + int rand $_; - %_ = qw(); + my %types = qw(); # At least 2 files for each available compression - foreach my $st (@SRCTYPES) { - next if ($$st{"type"} eq TYPE_GZIP && nogzip) - || ($$st{"type"} eq TYPE_BZIP2 && nobzip2); - @_ = grep !exists $_{$_}, (0...$num-1); - $_{$_[int rand @_]} = $st; - @_ = grep !exists $_{$_}, (0...$num-1); - $_{$_[int rand @_]} = $st; + foreach my $st (@SOURCE_TYPES) { + next if ($$st{"type"} eq TYPE_GZIP && has_no_gzip) + || ($$st{"type"} eq TYPE_BZIP2 && has_no_bzip2); + @_ = grep !exists $types{$_}, (0...$num-1); + $types{$_[int rand @_]} = $st; + @_ = grep !exists $types{$_}, (0...$num-1); + $types{$_[int rand @_]} = $st; } # Set random compression on the rest files - foreach (grep !exists $_{$_}, (0...$num-1)) { + foreach (grep !exists $types{$_}, (0...$num-1)) { do { - $_{$_} = $SRCTYPES[int rand @SRCTYPES]; - } until !(${$_{$_}}{"type"} eq TYPE_GZIP && nogzip) - && !(${$_{$_}}{"type"} eq TYPE_BZIP2 && nobzip2); + $types{$_} = $SOURCE_TYPES[int rand @SOURCE_TYPES]; + } until !(${$types{$_}}{"type"} eq TYPE_GZIP && has_no_gzip) + && !(${$types{$_}}{"type"} eq TYPE_BZIP2 && has_no_bzip2); } - @st = map $_{$_}, (0...$num-1); + @st = map $types{$_}, (0...$num-1); @fs = qw(); @cs = qw(); @cem = qw(); - @vardump = qw(); + @var_dump = qw(); @fle = qw(); %logfiles = qw(); for (my $k = 0; $k < $num; $k++) { - my ($logfile, $cs, $vardump); - do { $logfile = randword } until !exists $logfiles{$logfile}; + my ($logfile, $cs, $var_dump); + do { $logfile = random_word } until !exists $logfiles{$logfile}; $logfiles{$logfile} = 1; $logfile .= ${$st[$k]}{"suf"}; push @fs, catfile($WORKDIR, $logfile); - ($cs, $vardump, %_) = &{$$fmt{"sub"}}($fs[$k]); + ($cs, $var_dump, %types) = &{$$fmt{"sub"}}($fs[$k]); push @cs, $cs; - push @cem, {%_}; + push @cem, {%types}; push @fle, $logfile; - push @vardump, $vardump; - frwrite(catfile($WORKDIR, "$logfile.vardump"), $vardump); - push @fle, "$logfile.vardump"; + push @var_dump, $var_dump; + write_raw_file(catfile($WORKDIR, "$logfile.var-dump"), $var_dump); + push @fle, "$logfile.var-dump"; } - %_ = qw(); - %_ = (%_, map { $_ => 1 } keys %$_) foreach @cem; - @mle = sort keys %_; + %types = qw(); + %types = (%types, map { $_ => 1 } keys %$_) foreach @cem; + @mle = sort keys %types; $mt = pop @mle; - do { $oprfb = randword } until !exists $logfiles{$oprfb}; + do { $oprfb = random_word } until !exists $logfiles{$oprfb}; $opref = catfile($WORKDIR, $oprfb); - %cof = mkrndlog_existing $$fmt{"sub"}, + %cof = make_log_file $$fmt{"sub"}, $WORKDIR, "$oprfb.%s" . $$rt{"suf"}, @mle; push @fle, map basename($_), grep $cof{$_} ne "", keys %cof; - prsrvsrc $WORKDIR; + preserve_source $WORKDIR; $dup = $fs[int rand @fs]; $_ = int rand(@fs + 1); @_ = (@fs[0...$_-1], $dup, @fs[$_...$#fs]); @_ = ($arclog, qw(-d -d -d -o a), @{$$rt{"opts"}}, @_, $opref); $cmd = join(" ", @_); - ($retno, $out, $err) = runcmd "", @_; - ($fle, $flr) = (join(" ", sort @fle), flist $WORKDIR); + ($ret_no, $out, $err) = run_cmd "", @_; + ($fle, $flr) = (join(" ", sort @fle), list_files $WORKDIR); %cef = qw(); # Expected content by file %tef = qw(); # Expected file type by file %crf = qw(); # Resulted content by file @@ -206,76 +205,77 @@ $_ = eval { $fr = $fs[$k]; $frb = basename($fr); ($cef{$frb}, $tef{$frb}) = ($cs[$k], ${$st[$k]}{"type"}); - ($crf{$frb}, $trf{$frb}) = (fread $fr, ftype $fr); - $fr = $fs[$k] . ".vardump"; + ($crf{$frb}, $trf{$frb}) = (read_file $fr, file_type $fr); + $fr = $fs[$k] . ".var-dump"; $frb = basename($fr); - ($cef{$frb}, $tef{$frb}) = ($vardump[$k], TYPE_PLAIN); - ($crf{$frb}, $trf{$frb}) = (fread $fr, ftype $fr); + ($cef{$frb}, $tef{$frb}) = ($var_dump[$k], TYPE_TEXT); + ($crf{$frb}, $trf{$frb}) = (read_file $fr, file_type $fr); } foreach my $m (@mle) { $fr = "$opref.$m" . $$rt{"suf"}; $frb = basename($fr); next if $cof{$frb} eq ""; ($cef{$frb}, $tef{$frb}) = ($cof{$frb}, $$rt{"type"}); - ($crf{$frb}, $trf{$frb}) = (fread $fr, ftype $fr); + ($crf{$frb}, $trf{$frb}) = (read_file $fr, file_type $fr); } - die "$title\n$cmd\n$out$err" unless $retno != 0; + die "$title\n$cmd\n$out$err" unless $ret_no != 0; die "$title\n$cmd\nresult files incorrect.\nGot: $flr\nExpected: $fle\nOutput:\n$out$err" unless $flr eq $fle; foreach $fr (@fle) { die "$title\n$cmd\n$fr: result type incorrect.\nGot: $trf{$fr}\nExpected: $tef{$fr}\nOutput:\n$out$err" - unless nofile || $trf{$fr} eq $tef{$fr}; + unless has_no_file || $trf{$fr} eq $tef{$fr}; die "$title\n$cmd\n$fr: result incorrect.\nGot:\n$crf{$fr}\nExpected:\n$cef{$fr}\nOutput:\n$out$err" unless $crf{$fr} eq $cef{$fr}; } 1; }; ok($_, 1, $@); -cleanup $_, $WORKDIR, ++$tno; +clean_up $_, $WORKDIR, ++$tno; # 4-23: Mixing different formats -for (my $i = 0; $i < @LOGFMTS; $i++) { - for (my $j = 0; $j < @LOGFMTS; $j++) { +for (my $i = 0; $i < @LOG_FORMATS; $i++) { + for (my $j = 0; $j < @LOG_FORMATS; $j++) { next if $i == $j; $_ = eval { - my ($title, $cmd, $retno, $out, $err, @vardump, %logfiles); + my ($title, $cmd, $ret_no, $out, $err, @var_dump, %logfiles); my ($fr, $frb, @fle, $fle, $flr, %cef, %crf, %tef, %trf); my ($num, $swan, @fs, @cs, $opref, $oprfb); rmtree $WORKDIR; mkpath $WORKDIR; - $title = join ",", "Mixing formats", ${$LOGFMTS[$i]}{"title"}, - ${$LOGFMTS[$j]}{"title"}; + $title = join ",", "Mixing formats", ${$LOG_FORMATS[$i]}{"title"}, + ${$LOG_FORMATS[$j]}{"title"}; # 3-5 log files $num = 3 + int rand 3; $swan = 1 + int rand($num - 1); @fs = qw(); @cs = qw(); - @vardump = qw(); + @var_dump = qw(); @fle = qw(); %logfiles = qw(); for (my $k = 0; $k < $num; $k++) { - my ($logfile, $cs, $vardump); - do { $logfile = randword } until !exists $logfiles{$logfile}; + my ($logfile, $cs, $var_dump); + do { $logfile = random_word } until !exists $logfiles{$logfile}; $logfiles{$logfile} = 1; push @fs, catfile($WORKDIR, $logfile); + my %by_months; if ($k != $swan) { - ($cs, $vardump, %_) = &{${$LOGFMTS[$i]}{"sub"}}($fs[$k]); + ($cs, $var_dump, %by_months) = &{${$LOG_FORMATS[$i]}{"sub"}}($fs[$k]); } else { - ($cs, $vardump, %_) = &{${$LOGFMTS[$j]}{"sub"}}($fs[$k]); + ($cs, $var_dump, %by_months) = &{${$LOG_FORMATS[$j]}{"sub"}}($fs[$k]); } push @cs, $cs; push @fle, $logfile; - push @vardump, $vardump; - frwrite(catfile($WORKDIR, "$logfile.vardump"), $vardump); - push @fle, "$logfile.vardump"; + push @var_dump, $var_dump; + write_raw_file(catfile($WORKDIR, "$logfile.var-dump"), $var_dump); + push @fle, "$logfile.var-dump"; } - prsrvsrc $WORKDIR; - do { $oprfb = randword } until !exists $logfiles{$oprfb}; + preserve_source $WORKDIR; + do { $oprfb = random_word } until !exists $logfiles{$oprfb}; $opref = catfile($WORKDIR, $oprfb); @_ = ($arclog, qw(-d -d -d -c n), @fs, $opref); $cmd = join " ", @_; - ($retno, $out, $err) = runcmd "", @_; - ($fle, $flr) = (join(" ", sort @fle), flist $WORKDIR); + ($ret_no, $out, $err) = run_cmd "", @_; + ($fle, $flr) = (join(" ", sort @fle), list_files $WORKDIR); %cef = qw(); # Expected content by file %tef = qw(); # Expected file type by file %crf = qw(); # Resulted content by file @@ -283,26 +283,26 @@ for (my $i = 0; $i < @LOGFMTS; $i++) { for (my $k = 0; $k < $num; $k++) { $fr = $fs[$k]; $frb = basename($fr); - ($cef{$frb}, $tef{$frb}) = ($cs[$k], TYPE_PLAIN); - ($crf{$frb}, $trf{$frb}) = (fread $fr, ftype $fr); - $frb = "$frb.vardump"; + ($cef{$frb}, $tef{$frb}) = ($cs[$k], TYPE_TEXT); + ($crf{$frb}, $trf{$frb}) = (read_file $fr, file_type $fr); + $frb = "$frb.var-dump"; $fr = catfile($WORKDIR, $frb); - ($cef{$frb}, $tef{$frb}) = ($vardump[$k], TYPE_PLAIN); - ($crf{$frb}, $trf{$frb}) = (fread $fr, ftype $fr); + ($cef{$frb}, $tef{$frb}) = ($var_dump[$k], TYPE_TEXT); + ($crf{$frb}, $trf{$frb}) = (read_file $fr, file_type $fr); } - die "$title\n$cmd\n$out$err" unless $retno != 0; + die "$title\n$cmd\n$out$err" unless $ret_no != 0; die "$title\n$cmd\nresult files incorrect.\nGot: $flr\nExpected: $fle\nOutput:\n$out$err" unless $flr eq $fle; foreach $fr (@fle) { die "$title\n$cmd\n$fr: result type incorrect.\nGot: $trf{$fr}\nExpected: $tef{$fr}\nOutput:\n$out$err" - unless nofile || $trf{$fr} eq $tef{$fr}; + unless has_no_file || $trf{$fr} eq $tef{$fr}; die "$title\n$cmd\n$fr: result incorrect.\nGot:\n$crf{$fr}\nExpected:\n$cef{$fr}\nOutput:\n$out$err" unless $crf{$fr} eq $cef{$fr}; } 1; }; ok($_, 1, $@); - cleanup $_, $WORKDIR, ++$tno; + clean_up $_, $WORKDIR, ++$tno; die unless $_; } } diff --git a/t/_helper.pm b/t/_helper.pm index a2c59a2..6d8e3fd 100644 --- a/t/_helper.pm +++ b/t/_helper.pm @@ -1,65 +1,64 @@ # _helper.pm - A simple test suite helper -# Copyright (c) 2007 imacat -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . +# Copyright (c) 2007-2021 imacat. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. package _helper; use 5.005; use strict; use warnings; use base qw(Exporter); -use vars qw($VERSION @EXPORT); +our ($VERSION, @EXPORT); $VERSION = "0.01"; -@EXPORT = qw(); -push @EXPORT, qw(fread frread fwrite frwrite); -push @EXPORT, qw(runcmd whereis ftype flist prsrvsrc cleanup); -push @EXPORT, qw(nofile nogzip nobzip2); -push @EXPORT, qw(mkrndlog_existing); -push @EXPORT, qw(mkrndlog_apache mkrndlog_syslog); -push @EXPORT, qw(mkrndlog_ntp mkrndlog_apachessl mkrndlog_modfiso); -push @EXPORT, qw(randword); -push @EXPORT, qw(TYPE_PLAIN TYPE_GZIP TYPE_BZIP2); -push @EXPORT, qw(@LOGFMTS @SRCTYPES @RESTYPES @KEEPTYPES @OVERTYPES); +@EXPORT = qw( + read_file read_raw_file write_file write_raw_file + run_cmd where_is file_type list_files preserve_source clean_up + has_no_file has_no_gzip has_no_bzip2 + make_log_file + make_apache_log_file make_syslog_log_file + make_ntp_log_file make_apache_ssl_log_file make_modified_iso_log_file + random_word + TYPE_TEXT TYPE_GZIP TYPE_BZIP2 + @LOG_FORMATS @SOURCE_TYPES @RESULT_TYPES @KEEP_MODES @OVERRIDE_MODES); # Prototype declaration -sub thisfile(); -sub fread($); -sub frread($); -sub fwrite($$); -sub frwrite($$); -sub runcmd($@); -sub whereis($); -sub ftype($); -sub flist($); -sub prsrvsrc($); -sub cleanup($$$); -sub nofile(); -sub nogzip(); -sub nobzip2(); -sub mkrndlog_existing($$$@); -sub mkrndlog_apache($;$); -sub mkrndlog_syslog($;$); -sub mkrndlog_ntp($;$); -sub mkrndlog_apachessl($;$); -sub mkrndlog_modfiso($;$); -sub monrng_one($); -sub monrng_rand(); +sub this_file(); +sub read_file($); +sub read_raw_file($); +sub write_file($$); +sub write_raw_file($$); +sub run_cmd($@); +sub where_is($); +sub file_type($); +sub list_files($); +sub preserve_source($); +sub clean_up($$$); +sub has_no_file(); +sub has_no_gzip(); +sub has_no_bzip2(); +sub make_log_file($$$@); +sub make_apache_log_file($;$); +sub make_syslog_log_file($;$); +sub make_ntp_log_file($;$); +sub make_apache_ssl_log_file($;$); +sub make_modified_iso_log_file($;$); +sub month_range($); +sub random_month_ranges(); sub split_months(\@); sub insert_malformed(\@); -sub randword(); -sub randip(); -sub randdomain(); +sub random_word(); +sub random_ip(); +sub random_domain(); use Data::Dumper; use ExtUtils::MakeMaker qw(); @@ -72,386 +71,392 @@ use File::Temp qw(tempfile); use Time::Local qw(timelocal); $Data::Dumper::Indent = 1; -use vars qw(%WHEREIS $NOFILE $NOGZIP $NOBZIP2); -%WHEREIS = qw(); -undef $NOFILE; -undef $NOGZIP; -undef $NOBZIP2; +our (%WHERE_IS, $HAS_NO_FILE, $HAS_NO_GZIP, $HAS_NO_BZIP2); +%WHERE_IS = qw(); +undef $HAS_NO_FILE; +undef $HAS_NO_GZIP; +undef $HAS_NO_BZIP2; -use constant TYPE_PLAIN => "text/plain"; +use constant TYPE_TEXT => "text/plain"; use constant TYPE_GZIP => "application/x-gzip"; use constant TYPE_BZIP2 => "application/x-bzip2"; -use vars qw(@LOGFMTS @SRCTYPES @RESTYPES @KEEPTYPES @OVERTYPES); +our (@LOG_FORMATS, @SOURCE_TYPES, @RESULT_TYPES, @KEEP_MODES, @OVERRIDE_MODES); # All the log format information -@LOGFMTS = ( { "title" => "Apache acecss log", - "sub" => \&mkrndlog_apache, }, - { "title" => "Syslog", - "sub" => \&mkrndlog_syslog, }, - { "title" => "NTP", - "sub" => \&mkrndlog_ntp, }, - { "title" => "Apache SSL engine log", - "sub" => \&mkrndlog_apachessl, }, - { "title" => "modified ISO 8601 date/time", - "sub" => \&mkrndlog_modfiso, }, ); +@LOG_FORMATS = ( + { "title" => "Apache access log", + "sub" => \&make_apache_log_file, }, + { "title" => "Syslog", + "sub" => \&make_syslog_log_file, }, + { "title" => "NTP", + "sub" => \&make_ntp_log_file, }, + { "title" => "Apache SSL engine log", + "sub" => \&make_apache_ssl_log_file, }, + { "title" => "modified ISO 8601 date/time", + "sub" => \&make_modified_iso_log_file, }, ); # All the source type information -@SRCTYPES = ( { "title" => "plain text source", - "type" => TYPE_PLAIN, - "suf" => "", - "skip" => 0, }, - { "title" => "gzip source", - "type" => TYPE_GZIP, - "suf" => ".gz", - "skip" => nogzip, }, - { "title" => "bzip2 source", - "type" => TYPE_BZIP2, - "suf" => ".bz2", - "skip" => nobzip2, }, ); +@SOURCE_TYPES = ( + { "title" => "plain text source", + "type" => TYPE_TEXT, + "suf" => "", + "skip" => 0, }, + { "title" => "gzip source", + "type" => TYPE_GZIP, + "suf" => ".gz", + "skip" => has_no_gzip, }, + { "title" => "bzip2 source", + "type" => TYPE_BZIP2, + "suf" => ".bz2", + "skip" => has_no_bzip2, }, ); # All the result type information -@RESTYPES = ( { "title" => "default compress", - "type" => TYPE_GZIP, - "suf" => ".gz", - "skip" => nogzip, - "opts" => [], }, - { "title" => "gzip compress", - "type" => TYPE_GZIP, - "suf" => ".gz", - "skip" => nogzip, - "opts" => [qw(-c g)], }, - { "title" => "bzip2 compress", - "type" => TYPE_BZIP2, - "suf" => ".bz2", - "skip" => nobzip2, - "opts" => [qw(-c b)], }, - { "title" => "no compress", - "type" => TYPE_PLAIN, - "suf" => "", - "skip" => 0, - "opts" => [qw(-c n)], }, ); -# All the keep type information -@KEEPTYPES = ( { "title" => "keep default", - "opts" => [], - "tm" => 1, - "del" => 0, - "tmp" => 1, - "stdin" => 0, }, - { "title" => "keep all", - "opts" => [qw(-k a)], - "tm" => 0, - "del" => 0, - "tmp" => 0, - "stdin" => 0, }, - { "title" => "keep delete", - "opts" => [qw(-k d)], - "tm" => 0, - "del" => 1, - "tmp" => 1, - "stdin" => 0, }, - { "title" => "keep restart", - "opts" => [qw(-k r)], - "tm" => 0, - "del" => 0, - "tmp" => 1, - "stdin" => 0, }, - { "title" => "keep this month", - "opts" => [qw(-k t)], - "tm" => 1, - "del" => 0, - "tmp" => 1, - "stdin" => 0, }, - { "title" => "keep STDIN", - "opts" => [], - "tm" => 0, - "del" => 0, - "tmp" => 0, - "stdin" => 1, }, ); -# All the override type information -@OVERTYPES = ( { "title" => "override no existing", - "opts" => [], - "mkex" => 0, - "ok" => 1, - "ce" => sub { $_[1]; }, }, - { "title" => "override default", - "opts" => [], - "mkex" => 1, - "ok" => 0, - "ce" => sub { $_[0]; }, }, - { "title" => "override overwrite", - "opts" => [qw(-o o)], - "mkex" => 1, - "ok" => 1, - "ce" => sub { $_[1]; }, }, - { "title" => "override append", - "opts" => [qw(-o a)], - "mkex" => 1, - "ok" => 1, - "ce" => sub { $_[0] . $_[1]; }, }, - { "title" => "override ignore", - "opts" => [qw(-o i)], - "mkex" => 1, - "ok" => 1, - "ce" => sub { $_[0] || $_[1]; }, }, - { "title" => "override fail", - "opts" => [qw(-o f)], - "mkex" => 1, - "ok" => 0, - "ce" => sub { $_[0]; }, }, ); +@RESULT_TYPES = ( + { "title" => "default compress", + "type" => TYPE_GZIP, + "suf" => ".gz", + "skip" => has_no_gzip, + "opts" => [], }, + { "title" => "gzip compress", + "type" => TYPE_GZIP, + "suf" => ".gz", + "skip" => has_no_gzip, + "opts" => [qw(-c g)], }, + { "title" => "bzip2 compress", + "type" => TYPE_BZIP2, + "suf" => ".bz2", + "skip" => has_no_bzip2, + "opts" => [qw(-c b)], }, + { "title" => "no compress", + "type" => TYPE_TEXT, + "suf" => "", + "skip" => 0, + "opts" => [qw(-c n)], }, ); +# All the keep mode information +@KEEP_MODES = ( + { "title" => "keep default", + "opts" => [], + "tm" => 1, + "del" => 0, + "tmp" => 1, + "stdin" => 0, }, + { "title" => "keep all", + "opts" => [qw(-k a)], + "tm" => 0, + "del" => 0, + "tmp" => 0, + "stdin" => 0, }, + { "title" => "keep delete", + "opts" => [qw(-k d)], + "tm" => 0, + "del" => 1, + "tmp" => 1, + "stdin" => 0, }, + { "title" => "keep restart", + "opts" => [qw(-k r)], + "tm" => 0, + "del" => 0, + "tmp" => 1, + "stdin" => 0, }, + { "title" => "keep this month", + "opts" => [qw(-k t)], + "tm" => 1, + "del" => 0, + "tmp" => 1, + "stdin" => 0, }, + { "title" => "keep STDIN", + "opts" => [], + "tm" => 0, + "del" => 0, + "tmp" => 0, + "stdin" => 1, }, ); +# All the override mode information +@OVERRIDE_MODES = ( + { "title" => "override no existing", + "opts" => [], + "exists" => 0, + "ok" => 1, + "ce" => sub { $_[1]; }, }, + { "title" => "override default", + "opts" => [], + "exists" => 1, + "ok" => 0, + "ce" => sub { $_[0]; }, }, + { "title" => "override overwrite", + "opts" => [qw(-o o)], + "exists" => 1, + "ok" => 1, + "ce" => sub { $_[1]; }, }, + { "title" => "override append", + "opts" => [qw(-o a)], + "exists" => 1, + "ok" => 1, + "ce" => sub { $_[0] . $_[1]; }, }, + { "title" => "override ignore", + "opts" => [qw(-o i)], + "exists" => 1, + "ok" => 1, + "ce" => sub { $_[0] || $_[1]; }, }, + { "title" => "override fail", + "opts" => [qw(-o f)], + "exists" => 1, + "ok" => 0, + "ce" => sub { $_[0]; }, }, ); -# thisfile: Return the name of this file -sub thisfile() { basename($0); } +# Return the name of this file +sub this_file() { basename($0); } -# fread: A simple reader to read a log file in any supported format -sub fread($) { +# A simple reader to read a log file in any supported format +sub read_file($) { local ($_, %_); my ($file, $content); $file = $_[0]; - + # non-existing file return undef if !-e $file; - + # a gzip compressed file if ($file =~ /\.gz$/) { # Compress::Zlib if (eval { require Compress::Zlib; - import Compress::Zlib qw(gzopen); + Compress::Zlib->import(qw(gzopen)); 1; }) { + use Compress::Zlib qw(gzopen); my ($FH, $gz); $content = ""; - open $FH, $file or die thisfile . ": $file: $!"; - $gz = gzopen($FH, "rb") or die thisfile . ": $file: $!"; + open $FH, $file or die this_file . ": $file: $!"; + $gz = gzopen($FH, "rb") or die this_file . ": $file: $!"; while (1) { ($gz->gzread($_, 10240) != -1) - or die thisfile . ": $file: " . $gz->gzerror; + or die this_file . ": $file: " . $gz->gzerror; $content .= $_; last if length $_ < 10240; } - $gz->gzclose and die thisfile . ": $file: " . $gz->gzerror; + $gz->gzclose and die this_file . ": $file: " . $gz->gzerror; return $content; - + # gzip executable } else { my ($PH, $CMD); - $CMD = whereis "gzip"; + $CMD = where_is "gzip"; $CMD = "\"$CMD\" -cd \"$file\""; - open $PH, "$CMD |" or die thisfile . ": $CMD: $!"; + open $PH, "$CMD |" or die this_file . ": $CMD: $!"; $content = join "", <$PH>; - close $PH or die thisfile . ": $CMD: $!"; + close $PH or die this_file . ": $CMD: $!"; return $content; } - + # a bzip compressed file } elsif ($file =~ /\.bz2$/) { # Compress::Bzip2 if (eval { require Compress::Bzip2; - import Compress::Bzip2 2.00; - import Compress::Bzip2 qw(bzopen); + Compress::Bzip2->import(2.00); + Compress::Bzip2->import(qw(bzopen)); 1; }) { my ($FH, $bz); $content = ""; - open $FH, $file or die thisfile . ": $file: $!"; - $bz = bzopen($FH, "rb") or die thisfile . ": $file: $!"; + open $FH, $file or die this_file . ": $file: $!"; + $bz = bzopen($FH, "rb") or die this_file . ": $file: $!"; while (1) { ($bz->bzread($_, 10240) != -1) - or die thisfile . ": $file: " . $bz->bzerror; + or die this_file . ": $file: " . $bz->bzerror; $content .= $_; last if length $_ < 10240; } - $bz->bzclose and die thisfile . ": $file: " . $bz->bzerror; + $bz->bzclose and die this_file . ": $file: " . $bz->bzerror; return $content; - + # bzip2 executable } else { my ($PH, $CMD); - $CMD = whereis "bzip2"; + $CMD = where_is "bzip2"; $CMD = "bzip2 -cd \"$file\""; - open $PH, "$CMD |" or die thisfile . ": $CMD: $!"; + open $PH, "$CMD |" or die this_file . ": $CMD: $!"; $content = join "", <$PH>; - close $PH or die thisfile . ": $CMD: $!"; + close $PH or die this_file . ": $CMD: $!"; return $content; } - + # a plain text file } else { my $FH; - open $FH, $file or die thisfile . ": $file: $!"; + open $FH, $file or die this_file . ": $file: $!"; $content = join "", <$FH>; - close $FH or die thisfile . ": $file: $!"; + close $FH or die this_file . ": $file: $!"; return $content; } } -# frread: A raw file reader -sub frread($) { +# A raw file reader +sub read_raw_file($) { local ($_, %_); my ($file, $content, $FH, $size); $file = $_[0]; - + # non-existing file return undef if !-e $file; - + $size = (stat $file)[7]; - open $FH, $file or die thisfile . ": $file: $!"; - binmode $FH or die thisfile . ": $file: $!"; + open $FH, $file or die this_file . ": $file: $!"; + binmode $FH or die this_file . ": $file: $!"; (read($FH, $content, $size) == $size) - or die thisfile . ": $file: $!"; - close $FH or die thisfile . ": $file: $!"; + or die this_file . ": $file: $!"; + close $FH or die this_file . ": $file: $!"; return $content; } -# fwrite: A simple writer to write a log file in any supported format -sub fwrite($$) { +# A simple writer to write a log file in any supported format +sub write_file($$) { local ($_, %_); my ($file, $content); ($file, $content) = @_; - + # a gzip compressed file if ($file =~ /\.gz$/) { # Compress::Zlib if (eval { require Compress::Zlib; - import Compress::Zlib qw(gzopen); + Compress::Zlib->import(qw(gzopen)); 1; }) { my ($FH, $gz); - open $FH, ">$file" or die thisfile . ": $file: $!"; - $gz = gzopen($FH, "wb9") or die thisfile . ": $file: $!"; + open $FH, ">$file" or die this_file . ": $file: $!"; + $gz = gzopen($FH, "wb9") or die this_file . ": $file: $!"; ($gz->gzwrite($content) == length $content) - or die thisfile . ": $file: " . $gz->gzerror; - $gz->gzclose and die thisfile . ": $file: " . $gz->gzerror; + or die this_file . ": $file: " . $gz->gzerror; + $gz->gzclose and die this_file . ": $file: " . $gz->gzerror; return; - + # gzip executable } else { my ($PH, $CMD); - $CMD = whereis "gzip"; + $CMD = where_is "gzip"; $CMD = "\"$CMD\" -c9f > \"$file\""; - open $PH, "| $CMD" or die thisfile . ": $CMD: $!"; - print $PH $content or die thisfile . ": $CMD: $!"; - close $PH or die thisfile . ": $CMD: $!"; + open $PH, "| $CMD" or die this_file . ": $CMD: $!"; + print $PH $content or die this_file . ": $CMD: $!"; + close $PH or die this_file . ": $CMD: $!"; return; } - + # a bzip compressed file } elsif ($file =~ /\.bz2$/) { # Compress::Bzip2 if (eval { require Compress::Bzip2; - import Compress::Bzip2 2.00; - import Compress::Bzip2 qw(bzopen); + Compress::Bzip2->import(2.00); + Compress::Bzip2->import(qw(bzopen)); 1; }) { my ($FH, $bz); - open $FH, ">$file" or die thisfile . ": $file: $!"; - $bz = bzopen($FH, "wb9") or die thisfile . ": $file: $!"; + open $FH, ">$file" or die this_file . ": $file: $!"; + $bz = bzopen($FH, "wb9") or die this_file . ": $file: $!"; ($bz->bzwrite($content, length $content) == length $content) - or die thisfile . ": $file: " . $bz->bzerror; - $bz->bzclose and die thisfile . ": $file: " . $bz->bzerror; + or die this_file . ": $file: " . $bz->bzerror; + $bz->bzclose and die this_file . ": $file: " . $bz->bzerror; return; - + # bzip2 executable } else { my ($PH, $CMD); - $CMD = whereis "bzip2"; + $CMD = where_is "bzip2"; $CMD = "\"$CMD\" -9f > \"$file\""; - open $PH, "| $CMD" or die thisfile . ": $CMD: $!"; - print $PH $content or die thisfile . ": $CMD: $!"; - close $PH or die thisfile . ": $CMD: $!"; + open $PH, "| $CMD" or die this_file . ": $CMD: $!"; + print $PH $content or die this_file . ": $CMD: $!"; + close $PH or die this_file . ": $CMD: $!"; return; } - + # a plain text file } else { my $FH; - open $FH, ">$file" or die thisfile . ": $file: $!"; - print $FH $content or die thisfile . ": $file: $!"; - close $FH or die thisfile . ": $file: $!"; + open $FH, ">$file" or die this_file . ": $file: $!"; + print $FH $content or die this_file . ": $file: $!"; + close $FH or die this_file . ": $file: $!"; return; } } -# frwrite: A raw file writer -sub frwrite($$) { +# A raw file writer +sub write_raw_file($$) { local ($_, %_); my ($file, $content, $FH); ($file, $content) = @_; - - open $FH, ">$file" or die thisfile . ": $file: $!"; - binmode $FH or die thisfile . ": $file: $!"; - print $FH $content or die thisfile . ": $file: $!"; - close $FH or die thisfile . ": $file: $!"; + + open $FH, ">$file" or die this_file . ": $file: $!"; + binmode $FH or die this_file . ": $file: $!"; + print $FH $content or die this_file . ": $file: $!"; + close $FH or die this_file . ": $file: $!"; return; } -# runcmd: Run a command and return the result -sub runcmd($@) { +# Run a command and return the result +sub run_cmd($@) { local ($_, %_); - my ($retno, $out, $err, $in, @cmd, $cmd, $OUT, $ERR, $STDOUT, $STDERR, $PH); + my ($ret_no, $out, $err, $in, @cmd, $cmd, $OUT, $ERR, $STDOUT, $STDERR, $PH); ($in, @cmd) = @_; - + $err = "Running " . join(" ", map "\"$_\"", @cmd) . "\n"; $out = ""; - - open $STDOUT, ">&", \*STDOUT or die thisfile . ": STDOUT: $!"; - open $STDERR, ">&", \*STDERR or die thisfile . ": STDERR: $!"; - $OUT = tempfile or die thisfile . ": tempfile: $!"; - binmode $OUT or die thisfile . ": tempfile: $!"; - $ERR = tempfile or die thisfile . ": tempfile: $!"; - binmode $ERR or die thisfile . ": tempfile: $!"; - open STDOUT, ">&", $OUT or die thisfile . ": tempfile: $!"; - binmode STDOUT or die thisfile . ": tempfile: $!"; - open STDERR, ">&", $ERR or die thisfile . ": tempfile: $!"; - binmode STDERR or die thisfile . ": tempfile: $!"; - + + open $STDOUT, ">&", \*STDOUT or die this_file . ": STDOUT: $!"; + open $STDERR, ">&", \*STDERR or die this_file . ": STDERR: $!"; + $OUT = tempfile or die this_file . ": tempfile: $!"; + binmode $OUT or die this_file . ": tempfile: $!"; + $ERR = tempfile or die this_file . ": tempfile: $!"; + binmode $ERR or die this_file . ": tempfile: $!"; + open STDOUT, ">&", $OUT or die this_file . ": tempfile: $!"; + binmode STDOUT or die this_file . ": tempfile: $!"; + open STDERR, ">&", $ERR or die this_file . ": tempfile: $!"; + binmode STDERR or die this_file . ": tempfile: $!"; + $cmd = join " ", map "\"$_\"", @cmd; if ($^O eq "MSWin32") { - open $PH, "| $cmd" or die thisfile . ": $cmd: $!"; + open $PH, "| $cmd" or die this_file . ": $cmd: $!"; } else { - open $PH, "|-", @cmd or die thisfile . ": $cmd: $!"; + open $PH, "|-", @cmd or die this_file . ": $cmd: $!"; } - binmode $PH or die thisfile . ": $cmd: $!"; - print $PH $in or die thisfile . ": $cmd: $!"; + binmode $PH or die this_file . ": $cmd: $!"; + print $PH $in or die this_file . ": $cmd: $!"; close $PH; - $retno = $?; - - open STDOUT, ">&", $STDOUT or die thisfile . ": tempfile: $!"; - open STDERR, ">&", $STDERR or die thisfile . ": tempfile: $!"; - - seek $OUT, 0, SEEK_SET or die thisfile . ": tempfile: $!"; + $ret_no = $?; + + open STDOUT, ">&", $STDOUT or die this_file . ": tempfile: $!"; + open STDERR, ">&", $STDERR or die this_file . ": tempfile: $!"; + + seek $OUT, 0, SEEK_SET or die this_file . ": tempfile: $!"; $out = join "", <$OUT>; - close $OUT or die thisfile . ": tempfile: $!"; - seek $ERR, 0, SEEK_SET or die thisfile . ": tempfile: $!"; + close $OUT or die this_file . ": tempfile: $!"; + seek $ERR, 0, SEEK_SET or die this_file . ": tempfile: $!"; $err = join "", <$ERR>; - close $ERR or die thisfile . ": tempfile: $!"; - - return ($retno, $out, $err); + close $ERR or die this_file . ": tempfile: $!"; + + return ($ret_no, $out, $err); } -# whereis: Find an executable +# Find an executable # Code inspired from CPAN::FirstTime -sub whereis($) { +sub where_is($) { local ($_, %_); my ($file, $path); $file = $_[0]; - return $WHEREIS{$file} if exists $WHEREIS{$file}; + return $WHERE_IS{$file} if exists $WHERE_IS{$file}; foreach my $dir (path) { - return ($WHEREIS{$file} = $path) + return ($WHERE_IS{$file} = $path) if defined($path = MM->maybe_command(catfile($dir, $file))); } - return ($WHEREIS{$file} = undef); + return ($WHERE_IS{$file} = undef); } -# ftype: Find the file type -sub ftype($) { +# Find the file type +sub file_type($) { local ($_, %_); my $file; $file = $_[0]; return undef unless -e $file; # Use File::MMagic if (eval { require File::MMagic; 1; }) { - $_ = new File::MMagic->checktype_filename($file); + $_ = File::MMagic->new->checktype_filename($file); return "application/x-gzip" if /gzip/; return "application/x-bzip2" if /bzip2/; # All else are text/plain return "text/plain"; } # Use file executable - if (defined($_ = whereis "file")) { + if (defined($_ = where_is "file")) { $_ = join "", `"$_" "$file"`; return "application/x-gzip" if /gzip/; return "application/x-bzip2" if /bzip2/; @@ -462,45 +467,45 @@ sub ftype($) { return undef; } -# flist: Obtain the files list in a directory -sub flist($) { +# Obtain the files list in a directory +sub list_files($) { local ($_, %_); my ($dir, $DH); $dir = $_[0]; @_ = qw(); - opendir $DH, $dir or die thisfile . ": $dir: $!"; + opendir $DH, $dir or die this_file . ": $dir: $!"; while (defined($_ = readdir $DH)) { next if $_ eq "." || $_ eq ".." || !-f "$dir/$_"; push @_, $_; } - closedir $DH or die thisfile . ": $dir: $!"; + closedir $DH or die this_file . ": $dir: $!"; return join " ", sort @_; } -# prsrvsrc: Preserve the source test files -sub prsrvsrc($) { +# Preserve the source test files +sub preserve_source($) { local ($_, %_); my ($dir, $DH); $dir = $_[0]; @_ = qw(); - opendir $DH, $dir or die thisfile . ": $dir: $!"; + opendir $DH, $dir or die this_file . ": $dir: $!"; while (defined($_ = readdir $DH)) { next if $_ eq "." || $_ eq ".." || !-f "$dir/$_"; push @_, $_; } - closedir $DH or die thisfile . ": $dir: $!"; + closedir $DH or die this_file . ": $dir: $!"; rmtree "$dir/source"; mkpath "$dir/source"; - frwrite "$dir/source/$_", frread "$dir/$_" + write_raw_file "$dir/source/$_", read_raw_file "$dir/$_" foreach @_; return; } -# cleanup: Clean up the test files -sub cleanup($$$) { +# Clean up the test files +sub clean_up($$$) { local ($_, %_); - my ($r, $dir, $testno, $testname, $c); - ($r, $dir, $testno) = @_; + my ($r, $dir, $test_no, $test_name, $c); + ($r, $dir, $test_no) = @_; # Nothing to clean up return unless -e $dir; # Success @@ -509,47 +514,47 @@ sub cleanup($$$) { return; } # Fail - keep the test files for failure investigation - $testname = basename((caller)[1]); - $testname =~ s/\.t$//; + $test_name = basename((caller)[1]); + $test_name =~ s/\.t$//; $c = 1; - $c++ while -e ($_ = "$dir.$testname.$testno.$c"); - rename $dir, $_ or die thisfile . ": $dir, $_: $!"; + $c++ while -e ($_ = "$dir.$test_name.$test_no.$c"); + rename $dir, $_ or die this_file . ": $dir, $_: $!"; return; } -# nofile: If we have the file type checker somewhere -sub nofile() { - $NOFILE = eval { require File::MMagic; 1; } - || defined whereis "file"? +# If we have the file type checker somewhere +sub has_no_file() { + $HAS_NO_FILE = eval { require File::MMagic; 1; } + || defined where_is "file"? 0: "File::MMagic or file executable not available" - if !defined $NOFILE; - return $NOFILE; + if !defined $HAS_NO_FILE; + return $HAS_NO_FILE; } -# nogzip: If we have gzip support somewhere -sub nogzip() { - $NOGZIP = eval { require Compress::Zlib; 1; } - || defined whereis "gzip"? +# If we have gzip support somewhere +sub has_no_gzip() { + $HAS_NO_GZIP = eval { require Compress::Zlib; 1; } + || defined where_is "gzip"? 0: "Compress::Zlib or gzip executable not available" - if !defined $NOGZIP; - return $NOGZIP; + if !defined $HAS_NO_GZIP; + return $HAS_NO_GZIP; } -# nobzip2: If we have bzip2 support somewhere -sub nobzip2() { - $NOBZIP2 = eval { require Compress::Bzip2; import Compress::Bzip2 2.00; 1; } - || defined whereis "bzip2"? +# If we have bzip2 support somewhere +sub has_no_bzip2() { + $HAS_NO_BZIP2 = eval { require Compress::Bzip2; Compress::Bzip2->import(2.00); 1; } + || defined where_is "bzip2"? 0: "Compress::Bzip2 v2 or bzip2 executable not available" - if !defined $NOBZIP2; - return $NOBZIP2; + if !defined $HAS_NO_BZIP2; + return $HAS_NO_BZIP2; } -# mkrndlog_existing: Create a random existing log file -sub mkrndlog_existing($$$@) { +# Create a random existing log file +sub make_log_file($$$@) { local ($_, %_); - my ($mkrndlog, $dir, $filepat, @months, %contents); - ($mkrndlog, $dir, $filepat, @months) = @_; - + my ($make_log_file, $dir, $filename_pattern, @months, %contents); + ($make_log_file, $dir, $filename_pattern, @months) = @_; + # Find a non-decided month and have an existing log $_{$_[int rand @_]} = 1 if (@_ = grep !exists $_{$_}, @months) > 0; # Find a non-decided month and not have an existing log @@ -559,239 +564,239 @@ sub mkrndlog_existing($$$@) { %contents = qw(); foreach my $m (@months) { my ($file, $path); - $file = sprintf($filepat, $m); + $file = sprintf($filename_pattern, $m); $path = catfile($dir, $file); if ($_{$m}) { - $contents{$file} = (&$mkrndlog($path, $m))[0]; + $contents{$file} = (&$make_log_file($path, $m))[0]; } else { $contents{$file} = ""; } } - + return %contents; } -# mkrndlog_apache: Create a random Apache access log file -sub mkrndlog_apache($;$) { +# Create a random Apache access log file +sub make_apache_log_file($;$) { local ($_, %_); - my ($file, $month, @logs, $content, @monrng, %months, $vardump, $tz); + my ($file, $month, @logs, $content, @ranges, %months, $var_dump, $tz); ($file, $month) = @_; - + @logs = qw(); - + # Time zone $tz = (-12 + (int rand 53) / 2) * 3600; # To be removed #$tz = -12 + (int rand 53) / 2; #$tz = sprintf "%+05d", int($tz) * 100 + ($tz - int($tz)) * 60; - + # Get the range of a month if (defined $month) { - @monrng = monrng_one $month; + @ranges = month_range $month; # Get the range of some previous months } else { - @monrng = monrng_rand; + @ranges = random_month_ranges; } - for (my $i = 0; $i + 1 < @monrng; $i++) { + for (my $i = 0; $i + 1 < @ranges; $i++) { my $hosts; # 2-5 hosts $hosts = 2 + int rand 4; # Generate the visit time of each host for (my $j = 0; $j < $hosts; $j++) { - my ($host, $t, $user, $htver, @hlogs, $hlogs); + my ($host, $t, $user, $http_ver, @host_logs, $count); # Host type: 1: IP, 0: domain name - $host = int rand 2? randip: randdomain; - $t = $monrng[$i] + int rand($monrng[$i + 1] - $monrng[$i]); - $user = (0, 0, 1)[int rand 3]? "-": randword; - $htver = (qw(HTTP/1.1 HTTP/1.1 HTTP/1.1 HTTP/1.0))[int rand 4]; + $host = int rand 2? random_ip: random_domain; + $t = $ranges[$i] + int rand($ranges[$i + 1] - $ranges[$i]); + $user = (0, 0, 1)[int rand 3]? "-": random_word; + $http_ver = (qw(HTTP/1.1 HTTP/1.1 HTTP/1.1 HTTP/1.0))[int rand 4]; # 3-5 log records for each host - $hlogs = 3 + int rand 3; - @hlogs = qw(); - while (@hlogs < $hlogs) { - my ($ttxt, $method, $url, $dirs, @dirs, $type, $status, $size); + $count = 3 + int rand 3; + @host_logs = qw(); + while (@host_logs < $count) { + my ($time, $method, $url, $dirs, @dirs, $type, $status, $size); # Time text @_ = gmtime($t + $tz); $_[5] += 1900; $_[4] = (qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec))[$_[4]]; - $ttxt = sprintf "%02d/%s/%04d:%02d:%02d:%02d %+05d", + $time = sprintf "%02d/%s/%04d:%02d:%02d:%02d %+05d", @_[3,4,5,2,1,0], int($tz / 3600) * 100 + ($tz - int($tz / 3600) * 3600) / 60; - + $method = (qw(GET GET GET HEAD POST))[int rand 5]; - + # Generate a random URL # 0-3 levels of directories $dirs = int rand 4; @dirs = qw(); - push @dirs, "/" . randword while @dirs < $dirs; + push @dirs, "/" . random_word while @dirs < $dirs; $type = ("", qw(html html txt css png jpg))[int rand 7]; if ($type eq "") { $url = join("", @dirs) . "/"; } else { - $url = join("", @dirs) . "/" . randword . ".$type"; + $url = join("", @dirs) . "/" . random_word . ".$type"; } - + $status = (200, 200, 200, 200, 304, 400, 403, 404)[int rand 8]; if ($status == 304) { $size = 0; } else { $size = 200 + int rand 35000; } - push @hlogs, { + push @host_logs, { "time" => $t, "record" => sprintf("%s - %s [%s] \"%s %s %s\" %d %d\n", - $host, $user, $ttxt, - $method, $url, $htver, $status, $size), + $host, $user, $time, + $method, $url, $http_ver, $status, $size), }; - + # 0-2 seconds later $t += int rand 3; } - push @logs, @hlogs; + push @logs, @host_logs; # 0-5 seconds later $t += int rand 6; } } - + # Sort by time # A series of requests from a same host may run cross the next host # So we need to sort again @logs = sort { $$a{"time"} <=> $$b{"time"} } @logs; - + # Variables used, for failure investigation - $vardump = Data::Dumper->Dump([\@logs, $tz], [qw($logs $tz)]); - + $var_dump = Data::Dumper->Dump([\@logs, $tz], [qw($logs $tz)]); + # Split by months %months = split_months @logs; # Drop the time and keep the records @logs = map $$_{"record"}, @logs; # Insert 1-2 malformed lines insert_malformed @logs; - + # Compose the content $content = join "", @logs; # Output the file - fwrite($file, $content); + write_file($file, $content); # Return the content - return $content, $vardump, %months; + return $content, $var_dump, %months; } -# mkrndlog_syslog: Create a random Syslog log file -sub mkrndlog_syslog($;$) { +# Create a random Syslog log file +sub make_syslog_log_file($;$) { local ($_, %_); - my ($file, $month, @logs, $content, @monrng, %months, $vardump); + my ($file, $month, @logs, $content, @ranges, %months, $var_dump); my (@hosts, $hosts); ($file, $month) = @_; - + @logs = qw(); - + # 3-5 hosts $hosts = 3 + int rand 3; @hosts = qw(); - push @hosts, randword while @hosts < $hosts; - + push @hosts, random_word while @hosts < $hosts; + # Get the range of a month if (defined $month) { - @monrng = monrng_one $month; + @ranges = month_range $month; # Get the range of some previous months } else { - @monrng = monrng_rand; + @ranges = random_month_ranges; } - for (my $i = 0; $i + 1 < @monrng; $i++) { - my (@mlogs, $mlogs, @t); + for (my $i = 0; $i + 1 < @ranges; $i++) { + my (@month_logs, $count, @t); # 5-12 log records for each month - $mlogs = 5 + int rand 8; - @mlogs = qw(); + $count = 5 + int rand 8; + @month_logs = qw(); # Generate the time of each record @t = qw(); - push @t, $monrng[$i] + int rand($monrng[$i + 1] - $monrng[$i]) - while @t < $mlogs; + push @t, $ranges[$i] + int rand($ranges[$i + 1] - $ranges[$i]) + while @t < $count; foreach my $t (sort @t) { - my ($ttxt, $host, $app, $pid, $msg); + my ($time, $host, $app, $pid, $msg); # Time text @_ = localtime $t; $_[5] += 1900; $_[4] = (qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec))[$_[4]]; - $ttxt = sprintf "%s %2d %02d:%02d:%02d", @_[4,3,2,1,0]; + $time = sprintf "%s %2d %02d:%02d:%02d", @_[4,3,2,1,0]; $host = $hosts[int rand scalar @hosts]; - $app = (qw(kernel sendmail sshd su CRON), randword, randword)[int rand 5]; + $app = (qw(kernel sendmail sshd su CRON), random_word, random_word)[int rand 5]; # PID 2-65535 (PID 1 is init) $pid = 2 + int rand 65533; # 3-12 words for each message $_ = 3 + int rand 10; @_ = qw(); - push @_, randword while @_ < $_; + push @_, random_word while @_ < $_; $msg = join " ", @_; - - push @mlogs, { + + push @month_logs, { "time" => $t, "record" => sprintf("%s %s %s[%d] %s\n", - $ttxt, $host, $app, $pid, $msg), + $time, $host, $app, $pid, $msg), }; } - push @logs, @mlogs; + push @logs, @month_logs; } - + # Variables used, for failure investigation - $vardump = Data::Dumper->Dump([\@logs], [qw($logs)]); - + $var_dump = Data::Dumper->Dump([\@logs], [qw($logs)]); + # Split by months %months = split_months @logs; # Drop the time and keep the records @logs = map $$_{"record"}, @logs; # Insert 1-2 malformed lines insert_malformed @logs; - + # Compose the content $content = join "", @logs; # Output the file - fwrite($file, $content); + write_file($file, $content); # Return the content - return $content, $vardump, %months; + return $content, $var_dump, %months; } -# mkrndlog_ntp: Create a random NTP log file -sub mkrndlog_ntp($;$) { +# Create a random NTP log file +sub make_ntp_log_file($;$) { local ($_, %_); - my ($file, $month, @logs, $content, @monrng, %months, $vardump); + my ($file, $month, @logs, $content, @ranges, %months, $var_dump); my ($pid, $peers, @peers, $refs, @refs); ($file, $month) = @_; - + @logs = qw(); - + # PID 2-65535 (PID 1 is init) $pid = 2 + int rand 65533; # 3-5 peers $peers = 3 + int rand 3; @peers = qw(); - push @peers, randip while @peers < $peers; + push @peers, random_ip while @peers < $peers; # 2-3 references $refs = 2 + int rand 2; - push @refs, randip while @refs < $refs; - + push @refs, random_ip while @refs < $refs; + # Get the range of a month if (defined $month) { - @monrng = monrng_one $month; + @ranges = month_range $month; # Get the range of some previous months } else { - @monrng = monrng_rand; + @ranges = random_month_ranges; } - for (my $i = 0; $i + 1 < @monrng; $i++) { - my (@mlogs, $mlogs, @t); + for (my $i = 0; $i + 1 < @ranges; $i++) { + my (@month_logs, $count, @t); # 5-12 log records for each month - $mlogs = 5 + int rand 8; - @mlogs = qw(); + $count = 5 + int rand 8; + @month_logs = qw(); # Generate the time of each record @t = qw(); - push @t, $monrng[$i] + int rand($monrng[$i + 1] - $monrng[$i]) - while @t < $mlogs; + push @t, $ranges[$i] + int rand($ranges[$i + 1] - $ranges[$i]) + while @t < $count; foreach my $t (sort @t) { - my ($ttxt, $type, $msg); + my ($time, $type, $msg); # Time text @_ = localtime $t; $_[5] += 1900; $_[4] = (qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec))[$_[4]]; - $ttxt = sprintf "%2d %s %02d:%02d:%02d", @_[3,4,2,1,0]; + $time = sprintf "%2d %s %02d:%02d:%02d", @_[3,4,2,1,0]; # PID change - chance 2.73%, 50% change to total 25 records $pid = 2 + int rand 65533 if rand() < 0.0273; @@ -811,11 +816,11 @@ sub mkrndlog_ntp($;$) { } # Type 1 - reference host } elsif ($type == 1) { - my ($refhost, $stratum); - $refhost = $refs[int rand @refs]; + my ($ref_host, $stratum); + $ref_host = $refs[int rand @refs]; # Stratum 2-4 $stratum = 2 + int rand 2; - $msg = "synchronized to $refhost, stratum $stratum"; + $msg = "synchronized to $ref_host, stratum $stratum"; # Type 2 - clock set } elsif ($type == 2) { my ($off, $freq, $err, $poll); @@ -827,113 +832,113 @@ sub mkrndlog_ntp($;$) { $msg = sprintf "offset %8.6f sec freq %6.3f ppm error %8.6f poll %d", $off, $freq, $err, $poll; } - - push @mlogs, { + + push @month_logs, { "time" => $t, "record" => sprintf("%s ntpd[%d] %s\n", - $ttxt, $pid, $msg), + $time, $pid, $msg), }; } - push @logs, @mlogs; + push @logs, @month_logs; } - + # Variables used, for failure investigation - $vardump = Data::Dumper->Dump([\@logs], [qw($logs)]); - + $var_dump = Data::Dumper->Dump([\@logs], [qw($logs)]); + # Split by months %months = split_months @logs; # Drop the time and keep the records @logs = map $$_{"record"}, @logs; # Insert 1-2 malformed lines insert_malformed @logs; - + # Compose the content $content = join "", @logs; # Output the file - fwrite($file, $content); + write_file($file, $content); # Return the content - return $content, $vardump, %months; + return $content, $var_dump, %months; } -# mkrndlog_apachessl: Create a random Apache SSL engine log file -sub mkrndlog_apachessl($;$) { +# Create a random Apache SSL engine log file +sub make_apache_ssl_log_file($;$) { local ($_, %_); - my ($file, $month, @logs, $content, @monrng, %months, $vardump); + my ($file, $month, @logs, $content, @ranges, %months, $var_dump); my $host; ($file, $month) = @_; - + @logs = qw(); - - $host = randdomain; - + + $host = random_domain; + # Get the range of a month if (defined $month) { - @monrng = monrng_one $month; + @ranges = month_range $month; # Get the range of some previous months } else { - @monrng = monrng_rand; + @ranges = random_month_ranges; } - for (my $i = 0; $i + 1 < @monrng; $i++) { - my (@mlogs, $mlogs, @t); + for (my $i = 0; $i + 1 < @ranges; $i++) { + my (@month_logs, $count, @t); # 3-5 visitors for each month - $mlogs = 3 + int rand 3; - @mlogs = qw(); + $count = 3 + int rand 3; + @month_logs = qw(); # Generate the time of each record @t = qw(); - push @t, $monrng[$i] + int rand($monrng[$i + 1] - $monrng[$i]) - while @t < $mlogs; + push @t, $ranges[$i] + int rand($ranges[$i + 1] - $ranges[$i]) + while @t < $count; foreach my $t (sort @t) { - my ($ttxt, $pid, $remote, $priority, $child, $msg); + my ($time, $pid, $remote, $priority, $child, $msg); # Time text @_ = localtime $t; $_[5] += 1900; $_[4] = (qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec))[$_[4]]; - $ttxt = sprintf "%02d/%s/%04d %02d:%02d:%02d", @_[3,4,5,2,1,0]; + $time = sprintf "%02d/%s/%04d %02d:%02d:%02d", @_[3,4,5,2,1,0]; # PID 2-65535 (PID 1 is init) $pid = 2 + int rand 65533; # Remote client - $remote = randip; + $remote = random_ip; # Child number $child = int rand 15; - + # Error if (int rand 5 == 1) { $priority = "error"; $msg = "SSL handshake failed (server $host:443, client $remote) (OpenSSL library error follows)"; - push @mlogs, { + push @month_logs, { "time" => $t, "record" => sprintf("[%s %05d] [%s] %s\n", - $ttxt, $pid, $priority, $msg), + $time, $pid, $priority, $msg), }; $msg = "OpenSSL: error:1408E0F4:SSL routines:SSL3_GET_MESSAGE:unexpected message"; - push @mlogs, { + push @month_logs, { "time" => $t, "record" => sprintf("[%s %05d] [%s] %s\n", - $ttxt, $pid, $priority, $msg), + $time, $pid, $priority, $msg), }; - + # Info } else { $priority = "info"; $msg = "Connection to child $child established (server $host:443, client $remote)"; - push @mlogs, { + push @month_logs, { "time" => $t, "record" => sprintf("[%s %05d] [%s] %s\n", - $ttxt, $pid, $priority, $msg), + $time, $pid, $priority, $msg), }; $msg = "Seeding PRNG with 1164 bytes of entropy"; - push @mlogs, { + push @month_logs, { "time" => $t, "record" => sprintf("[%s %05d] [%s] %s\n", - $ttxt, $pid, $priority, $msg), + $time, $pid, $priority, $msg), }; # 1: bad if (int rand 2) { $msg = "Spurious SSL handshake interrupt[Hint: Usually just one of those OpenSSL confusions!?]"; - push @mlogs, { + push @month_logs, { "time" => $t, "record" => sprintf("[%s %05d] [%s] %s\n", - $ttxt, $pid, $priority, $msg), + $time, $pid, $priority, $msg), }; # 2: success } else { @@ -946,117 +951,117 @@ sub mkrndlog_apachessl($;$) { } else { $msg = "Subsequent (No.$j) HTTPS request received for child $child ($host:443)" } - push @mlogs, { + push @month_logs, { "time" => $t, "record" => sprintf("[%s %05d] [%s] %s\n", - $ttxt, $pid, $priority, $msg), + $time, $pid, $priority, $msg), }; } $msg = "Connection to child $child closed with standard shutdown (server $host:443, client $remote)"; - push @mlogs, { + push @month_logs, { "time" => $t, "record" => sprintf("[%s %05d] [%s] %s\n", - $ttxt, $pid, $priority, $msg), + $time, $pid, $priority, $msg), }; } } } - push @logs, @mlogs; + push @logs, @month_logs; } - + # Variables used, for failure investigation - $vardump = Data::Dumper->Dump([\@logs], [qw($logs)]); - + $var_dump = Data::Dumper->Dump([\@logs], [qw($logs)]); + # Split by months %months = split_months @logs; # Drop the time and keep the records @logs = map $$_{"record"}, @logs; # Insert 1-2 malformed lines insert_malformed @logs; - + # Compose the content $content = join "", @logs; # Output the file - fwrite($file, $content); + write_file($file, $content); # Return the content - return $content, $vardump, %months; + return $content, $var_dump, %months; } -# mkrndlog_modfiso: Create a random modified ISO 8861 date/time log file -sub mkrndlog_modfiso($;$) { +# Create a random modified ISO 8861 date/time log file +sub make_modified_iso_log_file($;$) { local ($_, %_); - my ($file, $month, @logs, $content, @monrng, %months, $vardump, $tz); + my ($file, $month, @logs, $content, @ranges, %months, $var_dump, $tz); ($file, $month) = @_; - + @logs = qw(); - + # Time zone $tz = (-12 + (int rand 53) / 2) * 3600; # To be removed #$tz = -12 + (int rand 53) / 2; #$tz = sprintf "%+05d", int($tz) * 100 + ($tz - int($tz)) * 60; - + # Get the range of a month if (defined $month) { - @monrng = monrng_one $month; + @ranges = month_range $month; # Get the range of some previous months } else { - @monrng = monrng_rand; + @ranges = random_month_ranges; } - for (my $i = 0; $i + 1 < @monrng; $i++) { - my (@mlogs, $mlogs, @t); + for (my $i = 0; $i + 1 < @ranges; $i++) { + my (@month_logs, $count, @t); # 5-12 log records for each month - $mlogs = 3 + int rand 3; - @mlogs = qw(); + $count = 3 + int rand 3; + @month_logs = qw(); # Generate the time of each record @t = qw(); - push @t, $monrng[$i] + int rand($monrng[$i + 1] - $monrng[$i]) - while @t < $mlogs; + push @t, $ranges[$i] + int rand($ranges[$i + 1] - $ranges[$i]) + while @t < $count; foreach my $t (sort @t) { - my ($ttxt, $id, $msg); + my ($time, $id, $msg); # Time text @_ = gmtime($t + $tz); $_[5] += 1900; $_[4]++; - $ttxt = sprintf "%04d-%02d-%02d %02d:%02d:%02d %+05d", - @_[5,4,3,2,1,0], + $time = sprintf "%04d-%02d-%02d %02d:%02d:%02d %+05d", + @_[5,4,3,2,1,0], int($tz / 3600) * 100 + ($tz - int($tz / 3600) * 3600) / 60; # identity - $id = randword; + $id = random_word; # 3-12 words for each message $_ = 3 + int rand 10; @_ = qw(); - push @_, randword while @_ < $_; + push @_, random_word while @_ < $_; $msg = join " ", @_; - push @mlogs, { + push @month_logs, { "time" => $t, "record" => sprintf("[%s] %s: %s\n", - $ttxt, $id, $msg), + $time, $id, $msg), }; } - push @logs, @mlogs; + push @logs, @month_logs; } - + # Variables used, for failure investigation - $vardump = Data::Dumper->Dump([\@logs, $tz], [qw($logs $tz)]); - + $var_dump = Data::Dumper->Dump([\@logs, $tz], [qw($logs $tz)]); + # Split by months %months = split_months @logs; # Drop the time and keep the records @logs = map $$_{"record"}, @logs; # Insert 1-2 malformed lines insert_malformed @logs; - + # Compose the content $content = join "", @logs; # Output the file - fwrite($file, $content); + write_file($file, $content); # Return the content - return $content, $vardump, %months; + return $content, $var_dump, %months; } -# monrng_one: Get the range of a specific month -sub monrng_one($) { +# Get the range of a specific month +sub month_range($) { local ($_, %_); my ($month, @range); $month = $_[0]; @@ -1078,8 +1083,8 @@ sub monrng_one($) { return @range; } -# monrng_rand: Get the range of some previous months -sub monrng_rand() { +# Get the range of some previous months +sub random_month_ranges() { local ($_, %_); my ($num, @range); # 1-3 previous months @@ -1099,12 +1104,12 @@ sub monrng_rand() { return @range; } -# split_months: Split the log records by months +# Split the log records by months sub split_months(\@) { local ($_, %_); my ($logs, %months); $logs = $_[0]; - + %months = qw(); foreach (@$logs) { my $month; @@ -1113,62 +1118,66 @@ sub split_months(\@) { $months{$month} = "" if !exists $months{$month}; $months{$month} .= $$_{"record"}; } - + return %months; } -# insert_malformed: Insert 1-2 malformed lines +# Insert 1-2 malformed lines sub insert_malformed(\@) { local ($_, %_); my ($logs, $malformed); $logs = $_[0]; - + $malformed = 1 + int rand 2; while ($malformed > 0) { my $line; # Generate the random malformed line $_ = 3 + int rand 5; @_ = qw(); - push @_, randword while @_ < $_; + push @_, random_word while @_ < $_; $line = join(" ", @_) . ".\n"; $line =~ s/^(.)/uc $1/e; # The position to insert the line # The position cannot be 0 - or we cannot judge the log format - $_ = 1 + int rand(@$logs - 1); + $_ = 1 + int rand(@$logs - 1); $logs = [@$logs[0...$_], $line, @$logs[$_+1...$#$logs]]; $malformed--; } - + return; } -# randword: Supply a random English word -sub randword() { +# Supply a random English word +sub random_word() { local ($_, %_); @_ = qw( -culminates spector thule tamil sages fasten bothers intricately librarian -mist criminate impressive scissor trance standardizing enabler athenians -planers decisions salvation wetness fibers cowardly winning call stockton -bifocal rapacious steak reinserts overhaul glaringly playwrights wagoner -garland hampered effie messy despaired orthodoxy bacterial bernardine driving -danization vapors uproar sects litmus sutton lacrosse); +hard-to-find striped poor scene miniature marble error shelter clear settle +march breath tested symptomatic delicate road punish grain fabulous camp +authority love system placid bake maddening sleep precious crabby lovely jolly +wrist park common volleyball tick judicious degree alluring hydrant oatmeal +aboard light spare delirious unwritten unnatural existence deadpan cagey +disastrous station fear dam adorable grape event silent extra-large shame meaty +husky drag religion extra-small pot valuable deceive obese seed history +wholesale tremble delightful leather cabbage death tub loss twig hate noxious +trashy sleet bleach quizzical familiar nappy teaching private yak turkey foolish +concentrate reject tacit goofy men ajar communicate); return $_[int rand @_]; } -# randip: Supply a random IP -sub randip() { +# Supply a random IP +sub random_ip() { return join ".", (int rand 255, int rand 255, int rand 255, 1 + int rand 254); } -# randdomain: Supply a random domain -sub randdomain() { +# Supply a random domain +sub random_domain() { local ($_, %_); # Generate a random domain name # 3-5 levels, end with net or com $_ = 2 + int rand 3; @_ = qw(); - push @_, randword while @_ < $_; + push @_, random_word while @_ < $_; push @_, (qw(net com))[int rand 2]; return join ".", @_; }