{"id":18822922,"url":"https://github.com/adaptiveconsulting/localstorage-logger","last_synced_at":"2025-04-14T01:24:10.247Z","repository":{"id":75325867,"uuid":"49420073","full_name":"AdaptiveConsulting/localstorage-logger","owner":"AdaptiveConsulting","description":"A rolling logger that logs to local storage","archived":false,"fork":false,"pushed_at":"2016-01-13T19:00:14.000Z","size":135,"stargazers_count":16,"open_issues_count":1,"forks_count":7,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-08T17:51:37.011Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/AdaptiveConsulting.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":"2016-01-11T10:55:19.000Z","updated_at":"2024-02-03T03:18:59.000Z","dependencies_parsed_at":"2023-03-17T21:30:38.762Z","dependency_job_id":null,"html_url":"https://github.com/AdaptiveConsulting/localstorage-logger","commit_stats":{"total_commits":16,"total_committers":1,"mean_commits":16.0,"dds":0.0,"last_synced_commit":"955f4ee067dce66a54686d233c0d61c21b9fae46"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdaptiveConsulting%2Flocalstorage-logger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdaptiveConsulting%2Flocalstorage-logger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdaptiveConsulting%2Flocalstorage-logger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdaptiveConsulting%2Flocalstorage-logger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AdaptiveConsulting","download_url":"https://codeload.github.com/AdaptiveConsulting/localstorage-logger/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248805680,"owners_count":21164368,"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-11-08T00:52:06.375Z","updated_at":"2025-04-14T01:24:10.221Z","avatar_url":"https://github.com/AdaptiveConsulting.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# localstorage-logger\nLogging library for writing to and exporting from local storage.\n\n## What is it?\n\nThis JavaScript library provides a mechanism to log to local storage and export the most recent entries. It will overwrite the oldest entries when writing a new entry if adding the entry makes the log bigger than `maxLogSizeInBytes`.\n\n## Motivation\nAt the time of writing, all the libraries we could find that provide logging or queuing in local storage used a single storage key. This means that they had to serialize the whole log/queue on any modification. This resulted in worse performance as the log got bigger.\n\nInstead of a single key, we use many keys. Therefore, the cost of serialization on each modification is much lower than in the other libraries we found. However, this means we lose atomicity when making modifications to the underlying data structure. JavaScript is single-threaded so this doesn't pose much of a problem but theoretically a browser crash at exactly the right moment could corrupt the underlying data structure built on top of local storage.\n\n## Usage\n\nThis is how you can use the logging functionality:\n\n```\nimport createLog from 'localstorage-logger';\n\nconst log = createLog({\n  logName: 'my-app-log-name',\n  maxLogSizeInBytes: 500 * 1024 // 500KB\n});\n\n// Log something\n// debug | info | warn | error\nlog.info('something', {\n  foo: 'bar'\n}, 42);\n\n// Export the log entries\nconst logEntries = log.exportToArray();\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadaptiveconsulting%2Flocalstorage-logger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadaptiveconsulting%2Flocalstorage-logger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadaptiveconsulting%2Flocalstorage-logger/lists"}