{"id":17083581,"url":"https://github.com/gnikonorov/golog","last_synced_at":"2026-06-19T16:31:39.313Z","repository":{"id":119155675,"uuid":"72391338","full_name":"gnikonorov/golog","owner":"gnikonorov","description":"logger for the Go programming language","archived":false,"fork":false,"pushed_at":"2020-02-17T21:39:57.000Z","size":43,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-24T20:39:52.614Z","etag":null,"topics":["golang","golang-library","logging"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gnikonorov.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":"2016-10-31T02:33:06.000Z","updated_at":"2020-08-26T19:53:39.000Z","dependencies_parsed_at":"2023-07-10T01:01:21.689Z","dependency_job_id":null,"html_url":"https://github.com/gnikonorov/golog","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/gnikonorov/golog","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gnikonorov%2Fgolog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gnikonorov%2Fgolog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gnikonorov%2Fgolog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gnikonorov%2Fgolog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gnikonorov","download_url":"https://codeload.github.com/gnikonorov/golog/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gnikonorov%2Fgolog/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34539675,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-19T02:00:06.005Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","golang-library","logging"],"created_at":"2024-10-14T13:02:50.762Z","updated_at":"2026-06-19T16:31:39.293Z","avatar_url":"https://github.com/gnikonorov.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/gnikonorov/golog.svg?branch=master)](https://travis-ci.org/gnikonorov/golog)\n\n# golog\n\n`golog` is a logger for the Go programming language.\n\n## Logging Levels\n\nThe logging levels shown below are provided by this logger, and are colorized if the logger is initialized with \n`colorize = true`.\n\n+ `Info`    ( Presented in the terminal's native colors )\n+ `Debug`   ( green text on the terminal's native background )\n+ `Warning` ( yellow text on the terminal's native background )\n+ `Error`   ( red text on the terminal's native background )\n+ `Fatal`   ( white text on a red background )\n+ `Panic`   ( white text on a red background )\n\n## Logging Modes\n\nThe logger may be set up to run in the three modes listed below. These modes are defined in `logging_output_modes.go`:\n\n+ `ModeScreen` - Output logs to `STDOUT`\n+ `ModeFile`   - Output logs to a user provided file\n+ `ModeBoth`   - Output logs to both `STDOUT` and a user provided file\n\n## Startup Actions\n\nUpon initialization of the logger, the user may specify what to do with an existing log file if the user has specified `ModeFile` or `ModeBoth` as their logging mode.\n\nThe following actions may be taken. These actions are defined in `logging_file_actions.go`:\n\n+ `FileActionAppend`   - If the log file to which the user is writing already exists, add new logs onto it\n+ `FileActionCompress` - If the log file to which the user is writing already exists, compress it into a `.gz` file\n+ `FileActionDelete`   - If the log file to which the user is writing already exists, delete it\n\nThe user may also specify `FileActionNone`. For now, this is logically equivalent to passing in `FileAppend`. \n\n## Initialization\n\nThe logger is a structure that may be initialized by the functions defined below\n\n### Raw Initializaion\n\nThe following arguments are passed in during initialization by calling `SetupLoggerFromFields`:\n\n+ `logMode (LoggingOutputMode)` - The mode the logger will operate in, as described in `Logging Modes`\n+ `logFileStartupAction (LoggingFileAction)` - Startup action taken by the logger as described in section `Startup Actions`\n+ `logDirectory (string)` - If `logMode` is `Both` or `File`, this is the directory to which the logger will write logs.\n+ `logFile (string)` - If the `logMode` is `Both` or `File`, this is the file to which the logger will write logs.\n+ `shouldColorize (bool)` - If set to `true` logging will be colorized as described in section `Logging Modes`.\n+ `isMock (bool)` - If set to `true` all filesystem ops will be stubbed by a fake filesystem as defined by [afero](https://github.com/spf13/afero)\n+ `isAsynch (bool)` - If set to `true` perform all logging asynchly in a seperate goroutine\n\nFor example:\n```\nlogger := golog.SetupLoggerFromFields(golog.ModeBoth, golog.FileActionNone, \"/path/to/log/file\", \"file.log\", true, false, true)\n```\n\n### Initialization From Struct\n\nThe logger may be initialized by creating a `LoggingConfig` struct and passing it to `SetupLoggerFromStruct`. \n\nThe definition for the struct is shown below:\n\n```\ntype LoggingConfig struct {\n\tName                 string            // The logger profile name\n\tLogMode              LoggingOutputMode // The logging mode\n\tLogFileStartupAction LoggingFileAction // The action the logger will take on startup\n\tLogDirectory         string            // The directory to which the logger writes\n\tLogFile              string            // The name of the log file to write to\n\tShouldColorize       bool              // Indicates if we should output information in color\n\tIsMock               bool              // If true, mock the filesystem via 'afero'\n\tIsAsynch             bool              // If true, Asynchly handle log requests\n}\n```\nA sample initialization would thus be as follows:\n\n```\nconfig := golog.LoggingConfig{LogMode: golog.Both, LogDirectory: \"/dir/to/my/go/project\", LogFile: \"important.log\", ShouldColorize: true, IsMock: false, IsAsynch: true}\nlogger := golog.SetupLoggerFromStruct(\u0026config)\n```\n### Initialization From JSON File\n\nThe logger may be initialized by specifying the path to a `JSON` file that contains its definition to `SetupLoggerFromConfigFile` along with the configuration profile name `name`. The `name` is what you have chosen to name a current configuration.\n\nA sample configuration file containing 3 profiles is shown below. Note how each entry has a configuration name `name`.\n\n```\n[{\n\t\"name\": \"test1\",\n\t\"logMode\": 1,                            // ModeFile\n\t\"logFileStartupAction\": 1,               // FileActionAppend\n\t\"logDirectory\": \"/dir/to/my/go/project\",\n\t\"logFile\": \"test1.log\",\n\t\"shouldColorize\": true,\n\t\"isMock\": true,\n\t\"isAsynch\": false\n}, {\n\t\"name\": \"test2\",\n\t\"logMode\": 2,                            // ModeScreen \n\t\"logFileStartupAction\": 2,               // FileActionCompress\n\t\"logDirectory\": \"/dir/to/my/go/project\",\n\t\"logFile\": \"test2.log\",\n\t\"shouldColorize\": true,\n\t\"isMock\": false,\n\t\"isAsynch\": false\n}, {\n\t\"name\": \"test3\",\n\t\"logMode\": 3,                            // ModeBoth\n\t\"logFileStartupAction\": 3,               // FileActionDelete\n\t\"logDirectory\": \"/dir/to/my/go/project\",\n\t\"logFile\": \"test3.log\",\n\t\"shouldColorize\": true,\n\t\"isMock\": true,\n\t\"isAsynch\": true\n}]\n```\n\nIf we wanted to initialize a logger to have the profile of `test1`, we would do the following:\n\n```\nvar profile = \"test1\"\nvar configFile = \"/path/to/my/config/config.json\"\nlogger := golog.SetupLoggerFromConfigFile(configFile, profile)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgnikonorov%2Fgolog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgnikonorov%2Fgolog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgnikonorov%2Fgolog/lists"}