{"id":15637729,"url":"https://github.com/megapixel99/environment-based-logging","last_synced_at":"2026-04-10T23:09:55.769Z","repository":{"id":57226001,"uuid":"205599234","full_name":"Megapixel99/Environment-Based-Logging","owner":"Megapixel99","description":"This is a npm module which manages logging between multiple environments.","archived":false,"fork":false,"pushed_at":"2019-09-01T04:58:31.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-07T00:28:32.140Z","etag":null,"topics":["env","environment","environment-variables","logging","nodejs","npm"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/environment-based-logging","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/Megapixel99.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}},"created_at":"2019-08-31T21:43:58.000Z","updated_at":"2019-09-01T04:58:33.000Z","dependencies_parsed_at":"2022-08-24T11:00:37.952Z","dependency_job_id":null,"html_url":"https://github.com/Megapixel99/Environment-Based-Logging","commit_stats":null,"previous_names":["megapixel99/env-logging"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Megapixel99%2FEnvironment-Based-Logging","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Megapixel99%2FEnvironment-Based-Logging/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Megapixel99%2FEnvironment-Based-Logging/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Megapixel99%2FEnvironment-Based-Logging/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Megapixel99","download_url":"https://codeload.github.com/Megapixel99/Environment-Based-Logging/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246243564,"owners_count":20746307,"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":["env","environment","environment-variables","logging","nodejs","npm"],"created_at":"2024-10-03T11:12:41.496Z","updated_at":"2025-10-30T09:17:56.220Z","avatar_url":"https://github.com/Megapixel99.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Environment Based Logging\n\nThis is a Logging library designed to be used with an application which has multiple environments.\n\nIt allows the user to customize their logs for different environments.\n\n## Installation\n\nnpm i environment-based-logging\n\n## Setup\n\n1. Create an environment file with the variable: LOG_LEVEL\n\n2. Use the following javascript in you file:\n```\nconst envLogger = require('environment-based-logging');\n\nvar logger_with_lower_levels = new envLogger({\n  env_file: \"path to environment file relative to your file (i.e. ../../environments/dev.env)\",\n  log_levels: {\n    test: 0,\n    dev: 1,\n    patch: 2\n  },\n  log_lower_levels: true\n});\n```\n\n3. Set LOG_LEVEL in your environment file to one of your log_levels (i.e. LOG_LEVEL=dev)\n\n### Parameters\n\n| Name | Type | Description | Default |\n|:-----|:----:|:------------|:-------:|\n| env_file | _string_ | The path to the environment file | _(required)_ |\n| log_levels | _string_ | The names of the levels and their level in regards to development, with production being the highest | _(required)_ |\n| log_lower_levels | _boolean_ | Determines whether lower levels should be logged | _false_ |\n\n## Usage\n\njavascript:\n```\nconst envLogger = require('environment-based-logging');\n\nvar logger_with_lower_levels = new envLogger({\n  env_file: \"../.env\",\n  log_levels: {\n    test: 0,\n    dev: 1,\n    patch: 2\n  },\n  log_lower_levels: true\n});\n\n//Outputs all of the logs since log_lower_levels is true\nlogger_with_lower_levels.print(\"test with lower level, level test \", \"test\");\nlogger_with_lower_levels.print(\"test with lower level, level dev \", \"dev\");\nlogger_with_lower_levels.print(\"test with lower level, level patch \", \"patch\");\n\nvar logger_without_lower_levels = new envLogger({\n  env_file: \"../.env\",\n  log_levels: {\n    test: 0,\n    dev: 1,\n    patch: 2\n  },\n  log_lower_levels: false\n});\n\n//Only outputs some of the logs depending on the since log_lower_levels is false\nlogger_without_lower_levels.print(\"test without lower level, level test \", \"test\");\nlogger_without_lower_levels.print(\"test without lower level, level dev \", \"dev\");\nlogger_without_lower_levels.print(\"test without lower level, level patch \", \"patch\");\n```\n\n## Example\n\nFor the usage case above, `LOG_LEVEL=dev` in the environment file will output:\n```\ntest with lower level, level test\ntest with lower level, level dev\ntest without lower level, level dev\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmegapixel99%2Fenvironment-based-logging","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmegapixel99%2Fenvironment-based-logging","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmegapixel99%2Fenvironment-based-logging/lists"}