{"id":26197431,"url":"https://github.com/golift/rotatorr","last_synced_at":"2025-08-22T07:18:48.879Z","repository":{"id":57557667,"uuid":"320806176","full_name":"golift/rotatorr","owner":"golift","description":"Log Rotation for Go Apps. Epic wave control in a bathing suit!","archived":false,"fork":false,"pushed_at":"2025-03-31T15:01:59.000Z","size":86,"stargazers_count":2,"open_issues_count":5,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-15T03:55:40.543Z","etag":null,"topics":["golang-library","golang-package","logfiles","logrotate","logrotation"],"latest_commit_sha":null,"homepage":"https://golift.io/discord","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/golift.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-12-12T10:41:19.000Z","updated_at":"2024-07-23T17:27:43.000Z","dependencies_parsed_at":"2024-04-25T06:22:49.527Z","dependency_job_id":"23842a45-9799-40e4-a297-d7b735835add","html_url":"https://github.com/golift/rotatorr","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/golift%2Frotatorr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/golift%2Frotatorr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/golift%2Frotatorr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/golift%2Frotatorr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/golift","download_url":"https://codeload.github.com/golift/rotatorr/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249003952,"owners_count":21196794,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["golang-library","golang-package","logfiles","logrotate","logrotation"],"created_at":"2025-03-12T02:27:05.559Z","updated_at":"2025-04-15T03:55:46.630Z","avatar_url":"https://github.com/golift.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Rotatorr\n\n## Go App Log Rotation!\n\n[![GoDoc](https://godoc.org/golift.io/rotatorr/svc?status.svg)](https://godoc.org/golift.io/rotatorr)\n[![Go Report Card](https://goreportcard.com/badge/golift.io/rotatorr)](https://goreportcard.com/report/golift.io/rotatorr)\n[![MIT License](http://img.shields.io/:license-mit-blue.svg)](https://github.com/golift/rotatorr/blob/master/LICENSE)\n[![discord](https://badgen.net/badge/icon/Discord?color=0011ff\u0026label\u0026icon=https://simpleicons.now.sh/discord/eee \"GoLift Discord\")](https://golift.io/discord)\n\n### Description\n\nRotatorr provides a simple `io.WriteCloser` you can plug into the default `log`\npackage. This interface handles log rotation while providing many features and\noverridable interfaces to customize the rotation experience. Inspired by\n[Lumberjack](https://github.com/natefinch/lumberjack). I wrote this because I\nwanted integer log files, and I figured why not fix a few of the things\nreported in the Lumberjack issues and pull requests.\n\n### Simple Usage\n\nThis example rotates logs once they reach 10mb. The backup log files have a\ntime stamp written to their name.\n```go\nlog.SetOutput(rotatorr.NewMust(\u0026rotatorr.Config{\n\tFilesize: 1024 * 1024 * 10, // 10 megabytes\n\tFilepath: \"/var/log/service.log\",\n\tRotatorr: \u0026timerotator.Layout{FileCount: 10},\n}))\n```\n\n### Advanced Usage\n\nIn the example above you can see that the `Rotatorr` interface is satisfied by\n`*timerotator.Layout`. The other built-in option is `*introtator.Layout`.\n\nAs a version 0 package, some of the interfaces are bound to change as we find bugs\nand make further improvements. Feedback and bug reports are welcomed and encouraged!\n\nThe [time rotator](https://pkg.go.dev/golift.io/rotatorr/timerotator)\nputs time stamps in the backup log file names.\nThe [int rotator](https://pkg.go.dev/golift.io/rotatorr/introtator)\nuses an integer (like `logfile.1.log`). Pick one and stick with it for best results.\nYou may also enable compression by adding a callback to either rotator that calls\nthe included [compressor](https://pkg.go.dev/golift.io/rotatorr/compressor) library.\n**All the advanced examples are in [godoc](https://pkg.go.dev/golift.io/rotatorr)**,\nor just check out the [examples_test.go](examples_test.go) file in this repo and the\n[example app](cmd/exampleapp/main.go) that's included.\nBelow you'll find the three main data structures you can provide to this\npackage to make log file rotation work just the way you want.\n\n#### Type: `rotatorr.Config`\n\nAll of the struct members are optional except the `Rotatorr` interface.\n\n```go\ntype Config struct {\n\tFilepath string        // Full path to log file. Set this, the default is lousy.\n\tFileMode os.FileMode   // POSIX mode for new files.\n\tDirMode  os.FileMode   // POSIX mode for new folders.\n\tEvery    time.Duration // Maximum log file age. Rotate every hour or day, etc.\n\tFileSize int64         // Maximum log file size in bytes. Default is unlimited (no rotation).\n\tRotatorr Rotatorr      // REQUIRED: Custom log Rotatorr. Use your own or one of the provided interfaces.\n}\n```\n\n#### Type: `introtator.Layout`\n\n -   `Rotatorr` interface.\n\n```go\ntype Layout struct {\n\tArchiveDir string // Location where rotated backup logs are moved to.\n\tFileCount  int    // Maximum number of rotated log files.\n\tFileOrder  Order  // Control the order of the integer-named backup log files.\n\tPostRotate func(fileName, newFile string)\n}\n```\n\n#### Type: `timerotator.Layout`\n\n-   `Rotatorr` interface.\n\n```go\ntype Layout struct {\n\tArchiveDir string        // Location where rotated backup logs are moved to.\n\tFileCount  int           // Maximum number of rotated log files.\n\tFileAge    time.Duration // Maximum age of rotated files.\n\tUseUTC     bool          // Sets the time zone to UTC when writing Time Formats (backup files).\n\tFormat     string        // Format for Go Time. Used as the name.\n\tJoiner     string        // The string betwene the file name prefix and time stamp. Default: -\n\tPostRotate func(fileName, newFile string)\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgolift%2Frotatorr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgolift%2Frotatorr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgolift%2Frotatorr/lists"}