2
0

27 Commits

Author SHA1 Message Date
s.solodyagin c207fc949a rename module 2026-03-29 18:23:26 +03:00
Lukas Rist 47ffae2331 cleanup and module support (#77)
* cleanup and module support
2020-10-21 10:19:57 -04:00
Deen 94d9e492cc use 0755 to create new dir (#68) 2019-04-11 14:44:13 -04:00
康晓宁 4b74a4dba9 fix a typo (#62) 2019-04-11 14:37:18 -04:00
Juan Osorio Robles 2e8fbeea3f Make default file permissions more restrictive (#83)
This asures that the process can still read and write its own log file,
but that other users cannot. This is a fairly standard mode for log
files in linux.
2019-04-11 10:42:26 -04:00
Tyler Butters aee4629129 Update docs, adding Compress setting details (#49) 2017-09-11 10:04:57 -04:00
Joel Sing a96e63847d Add support for log file compression (#43)
* Check test file content, not just length.

It is insufficient to just check the length of test files,
especially given that many of the tests result in multiple files
that have the same content/length. Instead, actually check that
the file content is what it is expected to be. Vary the content
that is being written so that the test failures become apparent.

This also fixes a case where the length of the wrong value is
checked following a write (it happens to work since the length
of the value checked is the same as that written).

* Make timeFromName actually return a time.

Simplify the timeFromName parsing (we only need to slice once,
not twice) and actually parse the extracted time in the
timeFromName function rather than returning an abitrary string
that may or may not be a time. Also conver the timeFromName
tests into table driven tests.

* Add support for compressing log files.

Rather than scanning for old log files (under lock) when a rotation
occurs, a goroutine is started when we first open or create a log
file. Post-rotation compression (if enabled) and removal of stale
log files is now designated to this goroutine.

Scanning, removal and compression are run in the same goroutine in
order to minimise background disk I/O, with removals being processed
prior to compression in order to free up disk space.

This results in a small change in existing behaviour - previously
only logs would be removed when the first rotation occurs, whereas
now logs will potentially be removed when logging first starts.

* Rework file ownership test.

Previously the test only verified that the code called Chown
but failed to verify what it actually called Chown on. This
reworks the code so that we have a fake file system that tracks
file ownership.

This also simplifies upcoming additional tests.

* Clone file owner and mode on compressed log.

Clone the log file owner and the log file mode to the compressed
log file. Add tests to ensure that this is handled correctly.
2017-05-31 12:03:50 -04:00
Nate Finch dd45e6a67c update docs w/ backup format info 2016-11-04 10:57:32 -04:00
Nate Finch 588a21fb0f Fix bug #12
Fixes bug #12. If the first write to a file would cause it to rotate, instead
of rotating, we'd just move it aside.  This change fixes that problem
by ensuring that we just run rotate in this situation, which does the
right thing (open new and then cleanup.)  Also added test to verify
the fix.
2015-05-20 21:59:18 -04:00
Nate Finch 689fc505a0 add changes to maintain perms and owner of logfile 2014-07-25 15:42:36 -04:00
Nate Finch 8b224001f4 fix a spot where an error was not properly returned 2014-07-23 05:46:04 -04:00
Nate Finch 3aa94be380 update readme and mention gopkg.in in godoc 2014-06-27 06:13:39 -04:00
Nate Finch 78d709c0cc v2 is go! 2014-06-27 06:04:13 -04:00
Nate Finch 72cc861377 Change definition of maxage to make it easier (i.e. possible) to load from a json/yaml/etc 2014-06-18 08:09:40 -04:00
Nate Finch 06f4f4ea5e go back to using defer to unlock in close and rotate 2014-06-16 15:29:37 -04:00
Nate Finch ffd1aed5ff make the code in Write a little more logical, and add a missing test, though the code worked correctly before. 2014-06-16 13:24:02 -04:00
Nate Finch fc6790d66f refactor internally a little to clean up the code. Make the main example a real example so we make sure it compiles 2014-06-16 12:55:21 -04:00
Nate Finch 03e9c77b42 remove erroneous old comment 2014-06-16 09:52:57 -04:00
Nate Finch 819bdb463d better version of check for io.WriteCloser 2014-06-16 09:46:03 -04:00
Nate Finch 6412f2cf51 move mutex to unexported field 2014-06-16 06:56:15 -04:00
Nate Finch 5aff0e0bbf add locks and the Rotate() function. Remove IsWriteTooLong function. Fix a bug in the link to time constants. 2014-06-16 06:48:32 -04:00
Nate Finch 245c33893c add code for always opening new with default dir and name. with test. 2014-06-15 08:53:04 -04:00
Nate Finch 29a1a3fa69 make golint happy 2014-06-15 08:14:23 -04:00
Nate Finch 625d6c6216 minor wording update 2014-06-15 08:12:37 -04:00
Nate Finch 1bb33e2fca more tests and fixed a bug the tests found. Cleaned up the documentation. Renamed Backups to MaxBackups. 2014-06-15 06:57:23 -04:00
Nate Finch 814d136090 update readme with godoc 2014-06-14 08:31:35 -04:00
Nate Finch 1c3db7d9ea initial code 2014-06-14 07:57:17 -04:00