{"id":18581913,"url":"https://github.com/coder/grip","last_synced_at":"2025-04-10T11:35:39.871Z","repository":{"id":43875911,"uuid":"265660185","full_name":"coder/grip","owner":"coder","description":"extensible logging and messaging framework for go processes. ","archived":false,"fork":false,"pushed_at":"2023-02-25T05:22:00.000Z","size":868,"stargazers_count":3,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-02T22:35:29.307Z","etag":null,"topics":["golang","logging","logging-and-metrics","logging-library","notifications","slack","splunk","structured-logging","syslog","systemd-journal"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/coder.png","metadata":{"files":{"readme":"README.rst","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-05-20T18:57:28.000Z","updated_at":"2025-03-03T05:28:06.000Z","dependencies_parsed_at":"2024-06-19T19:03:23.686Z","dependency_job_id":"7bd5a762-36ba-4dfb-85d8-ef6ae7f6d440","html_url":"https://github.com/coder/grip","commit_stats":null,"previous_names":["deciduosity/grip","cdr/grip"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coder%2Fgrip","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coder%2Fgrip/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coder%2Fgrip/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coder%2Fgrip/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coder","download_url":"https://codeload.github.com/coder/grip/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248208688,"owners_count":21065205,"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","logging","logging-and-metrics","logging-library","notifications","slack","splunk","structured-logging","syslog","systemd-journal"],"created_at":"2024-11-07T00:08:19.744Z","updated_at":"2025-04-10T11:35:34.831Z","avatar_url":"https://github.com/coder.png","language":"Go","readme":"====================================\n``grip`` -- A Golang Logging Library\n====================================\n\nOverview\n--------\n\nGrip is a high level logging and message system for providing a single\nsolution for structured logging, notification, and message sending.\n\n#. Provide a common logging interface with support for multiple\n   output/messaging backends.\n\n#. Provides some simple methods for errors, particularly when\n   you want to accumulate and then return errors.\n\n#. Provides tools for collecting structured logging information.\n\n*You just get a grip, folks.*\n\nUse\n---\n\n``grip`` declares its dependencies via go modules. The top level ``grip``\npackage provides global logging functions that use a global logging\ninterface. You can also use the logging package to produce logger objects with\nthe same interface to avoid relying on a global logger.\n\nGrip is available under the terms of the Apache License (v2.)\n\nDesign\n------\n\nInterface\n~~~~~~~~~\n\nGrip provides three main interfaces:\n\n- The ``send.Sender`` interfaces which implements sending messages to various\n  output sources. Provides sending as well as the ability to support error\n  handling, and message formating support.\n\n- The ``message.Composer`` which wraps messages providing both \"string\"\n  formating as well as a \"raw\" serialized approach.\n\n- The ``grip.Journaler`` interface provides a high level logging interface,\n  and is mirrored in the package's public interface as a defult logger.\n\nGoals\n~~~~~\n\n- Provide robust high-level abstractions for applications to manage messaging,\n  logging, and metrics collection.\n\n- Integrate with other logging systems (e.g. standard library logging,\n  standard output of subprocesses, other libraries, etc.)\n\n- Minimize operational complexity and dependencies for having robust logging\n  (e.g. make it possible to log effectively from within a program without\n  requiring log relays or collection agents.)\n\nDevelopment\n-----------\n\nFuture Work\n~~~~~~~~~~~\n\nGrip is relatively stable, though there are additional features and areas of\ndevelopment:\n\n- structured metrics collection. This involves adding a new interface as a\n  superset of the Composer interface, and providing ways of filtering these\n  messages out to provide better tools for collecting diagnostic data from\n  applications.\n\n- additional Sender implementations to support additional output formats and\n  needs.\n\n- better integration with recent development in error wrapping in the go\n  standard library.\n\nIf you encounter a problem please feel free to create a github issue or open a\npull request.\n\nHistory\n~~~~~~~\n\nGrip originated as a personal project, and became the default logging and\nmessaging tool for `Evergreen \u003chttps://github.com/evergreen-ci/\u003e`_ and related\nprojects at MongoDB's release infrastructure developer productivity\norganization.\n\nThis fork removes some legacy components and drops support older versions of\nGolang, thereby adding support for modules.\n\nFeatures\n--------\n\nOutput Formats\n~~~~~~~~~~~~~~\n\nGrip supports a number of different logging output backends:\n\n- systemd's journal (linux-only)\n- syslog (unix-only)\n- writing messages to standard output.\n- writing messages to a file.\n- sending messages to a slack's channel\n- sending messages to a user via XMPP (jabber.)\n- sending a desktop notification\n- sending an email.\n- sending log output.\n- create a tweet.\n\nSee the documentation of the `Sender interface\n\u003chttps://godoc.org/github.com/tychoish/grip/send#Sender\u003e`_ for more\ninformation on building new senders. The `base sender implementation\n\u003chttps://godoc.org/github.com/tychoish/grip/send#Base\u003e`_ implements most of\nthe interface, except for the Send method.\n\nIn addition to a collection of useful output implementations, grip also\nprovides tools for managing output including:\n\n- the `multi sender\n  \u003chttps://godoc.org/cdr.dev/grip/send#NewConfiguredMultiSender\u003e`_\n  for combining multiple senders to \"tee\" the output together,\n\n- the `buffering sender\n  \u003chttps://godoc.org/cdr.dev/grip/send#NewBufferedSender\u003e`_ for\n  wrapping a sender with a buffer that will batch messages after reciving a\n  specified number of messages, or on a specific interval.\n\n- the `io.Writer\n  \u003chttps://godoc.org/cdr.dev/grip/send#WriterSender\u003e`_ to convert a\n  sender implementation to an io.Writer, to be able to use grip fundamentals\n  in situations that call for ``io.Writers`` (e.g. the output of\n  subprocesses,.\n\n- the `WrapWriter\n  \u003chttps://godoc.org/cdr.dev/grip/send#WrapWriter\u003e`_ to use an\n  arbitrary ``io.Writer`` interface as a sender.\n\nLogging\n~~~~~~~\n\nProvides a fully featured level-based logging system with multiple\nbackends (e.g. send.Sender). By default logging messages are printed\nto standard output, but backends exists for many possible targets. The\ninterface for logging is provided by the Journaler interface.\n\nBy default ``grip.std`` defines a standard global  instances\nthat you can use with a set of ``grip.\u003cLevel\u003e`` functions, or you can\ncreate your own ``Journaler`` instance and embed it in your own\nstructures and packages.\n\nDefined helpers exist for the following levels/actions:\n\n- ``Debug``\n- ``Info``\n- ``Notice``\n- ``Warning``\n- ``Error``\n- ``Critical``\n- ``Alert``\n- ``Emergency``\n- ``EmergencyPanic``\n- ``EmergencyFatal``\n\nHelpers ending with ``Panic`` call ``panic()`` after logging the message\nmessage, and helpers ending with ``Fatal`` call ``os.Exit(1)`` after logging\nthe message. These are primarily for handling errors in your main() function\nand should be used sparingly, if at all, elsewhere.\n\nSender instances have a notion of \"default\" log levels and thresholds, which\nprovide the basis for verbosity control and sane default behavior. The default\nlevel defines the priority/level of any message with an invalid priority\nspecified. The threshold level, defines the minimum priority or level that\n``grip`` sends to the logging system. It's not possible to suppress the\nhighest log level, ``Emergency`` messages will always log.\n\n``Journaler`` objects have additional methods (also\navailable as functions in the ``grip`` package to manage and configure the\ninstance.\n\nError Collector for \"Continue on Error\" Semantics\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nIf you want to do something other than ignore or simply log errors, but don't\nwant to abort after an error, the `Catcher Interface\n\u003chttps://godoc.org/cdr.dev/grip#Catcher\u003e`_ provides a threadsafe\nway of aggregating errors. Consider: ::\n\n   func doStuff(dirname string) (error) {\n\t   files, err := ioutil.ReadDir(dirname)\n\t   if err != nil {\n\t\t   // should abort here because we shouldn't continue.\n\t\t   return err\n\t   }\n\n\t   catcher := grip.NewCatcher()t\n\t   for _, f := range files {\n\t       err = doStuffToFile(f.Name())\n\t       catcher.Add(err)\n\t   }\n\n\t   return catcher.Resolve()\n   }\n\nGrip provides several error catchers (which are independent of the logging\ninfrastructure.) They are Basic, Simple, and Extended. These variants differ\non how the collected errors are represented in the final error object. Basic\nuses the ``Error()`` method of component errors, Simple users\n``fmt.Sprintf(\"%s\", err)`` and Extended users ``fmt.Sprintf(\"%+v\",\nerr)``. There are also Timestamp methods that annotate all errors with a\ntimestamp of when the error was collected to improve debugability in longer\nrunning asynchronous contexts: these collectors rely on ``WrapErrorTime`` to\nannotate the timestamp, which may be useful in other contexts.\n\nConditional Logging\n~~~~~~~~~~~~~~~~~~~\n\n``grip`` incldues support for conditional logging, so that you can\nonly log a message in certain situations, by adding a Boolean argument\nto the logging call. Use this to implement \"log sometimes\" messages to\nminimize verbosity without complicating the calling code around the\nlogging, or simplify logging call sites. These methods have a ``\u003cLevel\u003eWhen```\nformat.\n\nThis is syntactic sugar around the `message.When\n\u003chttps://godoc.org/cdr.dev/grip/message#When\u003e`_ message type, but\ncan reduce a lot of nesting and call-site complexity.\n\nComposed Logging\n~~~~~~~~~~~~~~~~\n\nIf the production of the log message is resource intensive or\ncomplicated, you may wish to use a \"composed logging,\" which delays\nthe generation of the log message from the logging call site to the\nmessage propagation, to avoid generating the log message unless\nnecessary. Rather than passing the log message as a string, pass the\nlogging function an instance of a type that implements the\n``Composer`` interface.\n\nGrip uses composers internally, but you can pass composers directly to\nany of the basic logging method (e.g. ``Info()``, ``Debug()``) for\ncomposed logging.\n\nGrip includes a number of message types, including those that collect\nsystem information, process information, stacktraces, or simple\nuser-specified structured information.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoder%2Fgrip","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoder%2Fgrip","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoder%2Fgrip/lists"}