{"id":13807170,"url":"https://github.com/acquia/ember-logging-service","last_synced_at":"2025-05-14T00:31:01.949Z","repository":{"id":57224013,"uuid":"75664627","full_name":"acquia/ember-logging-service","owner":"acquia","description":"A generic ember logging service","archived":true,"fork":false,"pushed_at":"2018-06-18T16:11:08.000Z","size":193,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-05-01T00:40:14.069Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/acquia.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-12-05T20:44:44.000Z","updated_at":"2023-03-03T20:46:09.000Z","dependencies_parsed_at":"2022-08-30T02:10:34.891Z","dependency_job_id":null,"html_url":"https://github.com/acquia/ember-logging-service","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acquia%2Fember-logging-service","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acquia%2Fember-logging-service/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acquia%2Fember-logging-service/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acquia%2Fember-logging-service/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/acquia","download_url":"https://codeload.github.com/acquia/ember-logging-service/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253645441,"owners_count":21941315,"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":[],"created_at":"2024-08-04T01:01:21.958Z","updated_at":"2025-05-14T00:30:56.929Z","avatar_url":"https://github.com/acquia.png","language":"JavaScript","funding_links":[],"categories":["Packages"],"sub_categories":["Logging"],"readme":"# ember-logging-service [![Build Status](https://travis-ci.com/acquia/ember-logging-service.svg?token=xpbhY9xz7Z9aqH5aUfgP\u0026branch=master)](https://travis-ci.com/acquia/ember-logging-service)\n\nThis addon provides a general and extensible logging service that can be used\nthroughout your application.  This addon by itself will provide a basic logging\nservice that can be used to trigger log events as well as register consumers to\nlisten for events.\n\nExample consumers include:\n* https://github.com/acquia/ember-logging-amplitude/ for Amplitude integration\n* https://github.com/acquia/ember-logging-bugsnag/ for Bugsnag integration\n* https://github.com/acquia/ember-logging-flash-messages/ for Flash Messages integration\n\n# Installation\nThe addon can be installed using standard ember-cli syntax:\n```\nember install ember-logging-service\n```\n\n# Basic usage\nThe core functionality of ember-logging-service is a logging service that can\nbe injected using Ember's standard dependency injection functionality.\n\n```\nimport Ember from 'ember';\n\nexport default Ember.Component.extend({\n  logger: Ember.inject.service(),\n\n  trackSomethingAwesome() {\n    this.get('logger').info('Something awesome happened!!!', { who: 'Kermit' });\n  }\n});\n```\n\n# Concepts\n## Triggering events\nThe logging service categorizes each event with a 'level' and a 'tag'.  The level\nis meant as an indicator of the severity.  Currently the supported levels are:\ninfo, warning, and error.  These values are defined on the \"levels\" property\nof the logger service.  A tag is meant as a general user-defined categorization\nof a class of events.\n\nFor example, events tracking user behavior could all be tagged with 'user' such\nthat a user login would be triggered with the level of \"info\" and the tag of \"user\".\nTo trigger this type of event:\n\n`this.get('logger').info('user', 'Log in');`\n\nSimilarly, navigation events could be tracked as:\n`this.get('logger').info('navigation', 'About')`\n\nHelper functions are provided for each level for logging events.  Each function\ncan optionally accept additional data to be sent along with the event. \n```\nlet logger = this.get('service');\nlogger.info('user', 'Log out');\nlogger.warning('user', 'Cancelled save');\nlogger.error('error', 'API authorization error', { status: 403, foo: bar });\n```\n\n## Event consumers\nConsumers can register with the logging service to listen for any events matching\nthe a specific combination of event level and event tags.  For example, one\noutput may only care about error events and handle them accordingly by sending\nto Bugsnag or writing to a log.  Other tracking systems may care about user\ninteraction events for UX analyzation.\n\nA consumer can be registered with the logger by minimally providing an id, a\ncallback for events, a list of levels, and a list of tags.\n\nFor example:\n`this.get('logger').registerConsumer('muppets', happyFunc, 'info', ['sesame', 'muppets', monsters']);`\n\nTypically consumers are registered with application instance initializers within\na consumer addon.\n\nWhen an event is sent to the logger service that matches the level and tag combination\nfor a consumer, the consumer's callback function is triggered with a structured\nevent and the context of the application at the time of the event (more below).\n\nThe event is structured with the following data:\n* name: the name of the event trigger\n* type: the tag associated with the event\n* level: the severity level (info, warn, error)\n* metadata: any additional data passed when the event was triggered\n\nThe context object is structured with the following keys:\n* application: Any application-specific context provided\n* user: Any user-specific context provided\n\n## Application/User Context\nThe logger service can automatically include application and user context along\nwith each event.  This is the second parameter sent to the consumer callback\nmentioned above.  Because this information is specific to an application, it is\ngenerated by the application that consumes the logger service.  The logger service\nallows the registration of one or more application context callbacks and user\ncontext callbacks.  These callbacks are executed with each event to generate\na POJO of contextual information that can be used to provide additional context\nto consumers.  For example, it may be useful to provide customer API keys or\nthe current route within the application to give context to a navigation or \nerror event.\n\nBoth types of callbacks do not accept any parameters and return a POJO of custom\ninformation.\n\nAfter installing the ember-logging-service addon an application instance initializer\nis automatically created at `app/instance-initializers/register-logging-context.js`\n\nThis provides a sample registration of empty application and user context\ncallbacks.  This can be used as a guide to provide your own data into the\nplaceholder callbacks or to register your own service functions to provide the\ndata.\n\n## Automatic Error Monitoring \nWhen error handling is turned on, the logging service will automatically monitor\nany uncaught Ember or RSVP errors and send them as error level events.\n\n# Configuration\nTo enable ember-logging-service for an environment, include the following\nconfiguration information in your `config/environment.js`:\n\n```\nENV['ember-logging-service'] {\n  enabled: true\n}\n```\n\nTo enable ember-logging-service to handle basic error monitoring for an \nenvironment then include this additional property:\n\n```\nENV['ember-logging-service'] {\n  enabled: true,\n  errorsEnabled: true\n}\n```\n\n## Constants\nIt can be useful to refer to levels, tags, and events as variables rather than\nhard-coding the values in your code.  The service already provides the ability\nto refer to tags and levels by variable names rather than hard-coded strings.\n\nFor example:\n* `this.get('logger.levels.info')`\n* `this.get('logger.levels.warn')`\n* `this.get('logger.levels.error')`\n\nIf the logger is tracking the following tags: navigation, interaction, error:\n* `this.get('logger.tags.navigation')`\n* `this.get('logger.tags.interaction')`\n* `this.get('logger.tags.error')`\n\nConsider an example where you are tracking a user interaction event for a \nusability tracking system as \"Menu navigation\", but for purposes of reporting, \nyou UX department now requires you to track the event as \n\"Interaction - navigation - menu\".  If you had been tracking this event in\nmultiple places as `this.get('logger').info(this.get('logger.tags.interaction'), 'Menu navigation')`\nyou would need to update this event name in multiple places.\n\nYou could handle this in a couple of ways:\n* Maintain a list of strings on paper :(\n* Create a configuration of events in JSON format\n* Utilize an Ember service to define constant values\n\nThe logger service provides an optional mechanism to help with this.  If an\nobject of event data is passed in the configuration, the logger will automatically\nregister all of the tags and add the events into an object for easy reference.\n\nExample configuration:\n```\nENV['ember-logging-service'] {\n  enabled: true,\n  events: {\n    navgiation: {\n      ABOUT: 'About us',\n      HOME: 'Home',\n      CONTACT: 'Contact'\n    },\n    muppets: {\n      KERMIT: 'Kermie',\n      PIGGY: 'Piggy',\n      SWEDISH_CHEF: 'Swedish Chef'\n    }\n  }\n}\n```\nWith the above, all of the events will be available from the logger service\nbased on their tag:\n\n```\nlet logger = this.get('logger');\nconsole.log(logger.get('events.navigation.ABOUT')); // About us\nconsole.log(logger.get('events.muppets.KERMIT')); // Kermie\n```\n\nThis is not required for setting up the logger service and is only provided\nas a convenience mechanism.\n\n# Developing for ember-logging-service\n\n## Installation\n\n* `git clone git@github.com:acquia/ember-logging-service.git` this repository\n* `cd ember-logging-service`\n* `npm install`\n* `bower install`\n\n## Running\n\n* `ember serve`\n* Visit your app at [http://localhost:4200](http://localhost:4200).\n\n## Running Tests\n\n* `npm test` (Runs `ember try:each` to test your addon against multiple Ember versions)\n* `ember test`\n* `ember test --server`\n\n## Building\n\n* `ember build`\n\nFor more information on using ember-cli, visit [https://ember-cli.com/](https://ember-cli.com/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Facquia%2Fember-logging-service","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Facquia%2Fember-logging-service","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Facquia%2Fember-logging-service/lists"}