{"id":16612169,"url":"https://github.com/shufo/activity_log","last_synced_at":"2025-03-21T14:31:09.696Z","repository":{"id":26005944,"uuid":"107081452","full_name":"shufo/activity_log","owner":"shufo","description":"A logger with Activitiy Streams like format for Elixir","archived":false,"fork":false,"pushed_at":"2023-12-15T11:56:12.000Z","size":12,"stargazers_count":2,"open_issues_count":8,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-05-01T21:22:11.127Z","etag":null,"topics":["elixir"],"latest_commit_sha":null,"homepage":"https://hex.pm/packages/activity_log","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shufo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2017-10-16T05:22:01.000Z","updated_at":"2020-01-12T18:58:42.000Z","dependencies_parsed_at":"2023-12-15T12:44:17.704Z","dependency_job_id":"ec3d89d3-e5ac-4e14-8f92-99c28e3712e5","html_url":"https://github.com/shufo/activity_log","commit_stats":{"total_commits":1,"total_committers":1,"mean_commits":1.0,"dds":0.0,"last_synced_commit":"e8e93ade1395f15f023ef70b063a2eecf5551cc7"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shufo%2Factivity_log","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shufo%2Factivity_log/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shufo%2Factivity_log/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shufo%2Factivity_log/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shufo","download_url":"https://codeload.github.com/shufo/activity_log/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244815132,"owners_count":20514896,"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":["elixir"],"created_at":"2024-10-12T01:41:18.952Z","updated_at":"2025-03-21T14:31:09.438Z","avatar_url":"https://github.com/shufo.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ActivityLog\n\nLogging activities with [Activitiy Streams](https://www.w3.org/TR/activitystreams-core/) like format (not the same, but inspired).\n\n## Installation\n\n```elixir\ndef deps do\n  [\n    {:activity_log, \"~\u003e 0.1.0\"}\n  ]\nend\n```\n\n## Usage\n\nDefine your activities.\n\n```elixir\ndefmodule MyApp.Activity.Article do\n  use ActivityLog\n\n  activity \"create\" do\n    actor  :user\n    object :article\n  end\n\n  def name(actor, object), do: \"#{actor.name} created #{object.name}\"\nend\n```\n\nCreate activity.\n\n\n```elixir\niex\u003e alias MyApp.Activity.Article\niex\u003e activity = %Article{actor: %Article.Actor{id: 1, name: \"foo\"}, object: %Article.Object{id: 1, name: \"My article\"}}\niex\u003e ActivityLog.add(activity)\n# outputs\n05:29:32.128 [info]  {\"type\":\"create\",\"target\":null,\"object\":{\"type\":\"article\",\"name\":\"My article\",\"id\":1},\"name\":\"foo createed My article\",\"actor\":{\"type\":\"user\",\"name\":\"foo\",\"id\":1},\"@timestamp\":\"2017-10-15T20:29:32.128192Z\",\"@context\":\"https://github.com/shufo/activity_log\"}\n:ok\n```\n\n## How to\n\n### Define target\n\nIf you want to add the `target` property, define target in your activity module.\n\n```elixir\ndefmodule MyApp.Activity.Comment do\n  use ActivityLog\n\n  activity \"add\" do\n    actor  :user\n    object :comment\n    target :article\n  end\n\n  def name(actor, object, target), do: \"#{actor.name} commented #{object.name} to #{target.name}\"\nend\n\niex\u003e alias MyApp.Activity.Comment\n# create activity\niex\u003e activity = %Comment{actor: %Comment.Actor{id: 1, name: \"foo\"}, object: %Comment.Object{id: 2, name: \"Nice article!\"}, target: %Comment.Target{id: 3, name: \"My article\"}}\niex\u003e ActivityLog.add(activity)\n# =\u003e 05:27:34.877 [info]  {\"type\":\"add\",\"target\":{\"type\":\"article\",\"name\":\"My article\",\"id\":3},\"object\":{\"type\":\"comment\",\"name\":\"Nice article!\",\"id\":2},\"name\":\"foo commented Nice article! to My article\",\"actor\":{\"type\":\"user\",\"name\":\"foo\",\"id\":1},\"@timestamp\":\"2017-10-15T20:27:34.877639Z\",\"@context\":\"https://github.com/shufo/activity_log\"}\n:ok\n```\n\n### Change Logger\n\nDefault logger is Elixir's built-in [Logger](https://hexdocs.pm/logger/Logger.html).\n\nIf you want to change the logging backend, define your logger and configuration.\n\n```elixir\nconfig :activity_log, backends: [YourApp.Logger]\n```\n\nYou need to implement the `Activity.Logger` behaviour. (`add/2`)\n\n```elixir\ndefmodule YourApp.Logger do\n  def add(activity, opts \\\\ []) do\n    # do something\n  end\nend\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshufo%2Factivity_log","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshufo%2Factivity_log","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshufo%2Factivity_log/lists"}