{"id":34156757,"url":"https://github.com/bnclabs/golog","last_synced_at":"2026-03-09T22:03:04.571Z","repository":{"id":68691376,"uuid":"86710393","full_name":"bnclabs/golog","owner":"bnclabs","description":"Basic logging for go libraries and applications.","archived":false,"fork":false,"pushed_at":"2021-02-10T11:14:14.000Z","size":1711,"stargazers_count":1,"open_issues_count":2,"forks_count":2,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-08-14T21:34:25.005Z","etag":null,"topics":["golang","logger","logging"],"latest_commit_sha":null,"homepage":"","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/bnclabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-03-30T14:13:08.000Z","updated_at":"2021-02-10T11:14:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"248a82b5-3726-412a-b04b-2687068b82eb","html_url":"https://github.com/bnclabs/golog","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bnclabs/golog","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bnclabs%2Fgolog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bnclabs%2Fgolog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bnclabs%2Fgolog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bnclabs%2Fgolog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bnclabs","download_url":"https://codeload.github.com/bnclabs/golog/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bnclabs%2Fgolog/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30314405,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-09T20:05:46.299Z","status":"ssl_error","status_checked_at":"2026-03-09T19:57:04.425Z","response_time":61,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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","logger","logging"],"created_at":"2025-12-15T07:28:48.058Z","updated_at":"2026-03-09T22:03:04.561Z","avatar_url":"https://github.com/bnclabs.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"Basic logging with batteries\n----------------------------\n\n[![Build Status](https://travis-ci.org/bnclabs/golog.png)](https://travis-ci.org/bnclabs/golog)\n[![Coverage Status](https://coveralls.io/repos/github/bnclabs/golog/badge.svg?branch=master)](https://coveralls.io/github/bnclabs/golog?branch=master)\n[![GoDoc](https://godoc.org/github.com/bnclabs/golog?status.png)](https://godoc.org/github.com/bnclabs/golog)\n[![GitPitch](https://gitpitch.com/assets/badge.svg)](https://gitpitch.com/bnclabs/golog/master?grs=github\u0026t=white)\n\n* APIs to prefix log-level in log messages.\n* Global option to redirect logs to a file.\n* Include/Exclude/Format log time.\n* Colorize log messages for different levels.\n* Console logging.\n* Stable APIs, existing APIs are not going to change.\n\nHow to use golog\n----------------\n\nPackages can import golog and use its methods\n\n```go\nimport github.com/bnclabs/golog\nfunc myfunc() {\n    ..\n    log.Fatalf(...)\n    ..\n    log.Warnf(...)\n    ..\n    log.Debugf(...)\n}\n```\n\nNote here that *log* is not an object name, importing *golog* resolves to\n*log* package that has exported methods *Fatalf()* *Warnf()* etc ... For more\ninformation please read the go-documentation for *log* package.\n\nBy default, importing the package will initialize the logger to\ndefault-logger that shall log to standard output. To use custom logger\nuse the following initializer function in your package or application:\n\n```go\nimport github.com/bnclabs/golog\n\nvar mylogger = newmylogger()\nfunc init() {\n    setts := map[string]interface{}{\n        \"log.level\": \"info\",\n        \"log.file\":  \"\",\n    }\n    SetLogger(mylogger, setts)\n}\n```\n\n*mylogger* should implement the *log.Logger* interface{}.\n\n**Order of log levels**\n\n```golang\nconst (\n\tlogLevelIgnore LogLevel = iota + 1\n\tlogLevelFatal\n\tlogLevelError\n\tlogLevelWarn\n\tlogLevelInfo\n\tlogLevelVerbose\n\tlogLevelDebug\n\tlogLevelTrace\n)\n```\n\nConsole Logging\n---------------\n\nBy default log APIs will worry about log-level, prefix format, time-format\nsometimes it become too much of clutter on the screen to communicate simple\nmessages with user via console. In such cases use the `Consolef` API.\n\n```go\n    log.Consolef(\"goledger version - goledger%v\\n\", api.LedgerVersion)\n```\n\n`Consolef` does not print the log time, log level and always outputs to\nstdout.\n\nSettings\n--------\n\n* **log.level**, filter all messages logged at level greater than the\n  configured value. Can be one of the following names -\n  ignore, fatal, error, warn, info, verbose, debug, trace\n* **log.flag**, comma separated value of log.Flags,\n  eg: `Ldate,Ltime,Llongfile`, described further down.\n* **log.file**, if not empty string, all log messages are appended to\n  configured file.\n* **log.timeformat**, format of time string prefixed to log message,\n  should confirm to `time.Now().Format()`.\n* **log.prefix**, `fmt.Sprintf` format string for log level, by\n  default `[\u003cleve\u003e]` format is used.\n* **log.colorfatal**, comma separated value of attribute names -\n  bold, underline, blinkslow, blinkrapid, crossedout, red, green,\n  yellow, blue, magenta, cyan, white, hired, higreen, hiyellow, hiblue,\n  himagenta, hicyan, hiwhite. Attribute-settings available for all log levels.\n\n**Ignore** ignore level can be used to ignore all log messages. Note that\nonly log-level can be specified as `ignore`, no corresponding API\nis supported.\n\n**log.flags**\n\n```go\nconst (\n    // Bits or'ed together to control what's printed.\n    // There is no control over the order they appear (the order listed\n    // here) or the format they present (as described in the comments).\n    // The prefix is followed by a colon only when Llongfile or Lshortfile\n    // is specified.\n    // For example, flags Ldate | Ltime (or LstdFlags) produce,\n    //  2009/01/23 01:23:23 message\n    // while flags Ldate | Ltime | Lmicroseconds | Llongfile produce,\n    //  2009/01/23 01:23:23.123123 /a/b/c/d.go:23: message\n    Ldate         = 1 \u003c\u003c iota     // the date in the local time zone: 2009/01/23\n    Ltime                         // the time in the local time zone: 01:23:23\n    Lmicroseconds                 // microsecond resolution: 01:23:23.123123.  assumes Ltime.\n    Llongfile                     // full file name and line number: /a/b/c/d.go:23\n    Lshortfile                    // final file name element and line number: d.go:23. overrides Llongfile\n    LUTC                          // if Ldate or Ltime is set, use UTC rather than the local time zone\n    LstdFlags     = Ldate | Ltime // initial values for the standard logger\n)\n```\n\nDefault **log.level** is `Info`.\n\nPanic and recovery\n------------------\n\n* API `SetLogger()`\n  * If `log.file` is not string.\n  * If creating or opening `log.file` fails.\n  * If `log.level` is not an allowed log string.\n  * If `log.prefix` is neither string, nor bool.\n* API `SetLogLevel()`\n  * If `log.level` is not an allowed log string.\n* API `SetLogprefix()`\n  * If `log.prefix` is neither string, nor bool.\n\nTypically all the above panic cases needs to be fixed during development, and\nshould never occur during production. If panics become unavoidable please use\n[panic/recover](https://blog.golang.org/defer-panic-and-recover).\n\nHow to contribute\n-----------------\n\n* Pick an issue, or create an new issue. Provide adequate documentation for\n  the issue.\n* Assign the issue or get it assigned.\n* Work on the code, once finished, raise a pull request.\n* Golog is written in [golang](https://golang.org/), hence expected to\n  follow the global guidelines for writing go programs.\n* As of now, branch `master` is the development branch.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbnclabs%2Fgolog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbnclabs%2Fgolog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbnclabs%2Fgolog/lists"}