{"id":13544692,"url":"https://github.com/Syed-Umair/logger","last_synced_at":"2025-04-02T14:31:45.943Z","repository":{"id":52416971,"uuid":"100590275","full_name":"Syed-Umair/logger","owner":"Syed-Umair","description":"Logger for Electron Applications","archived":false,"fork":false,"pushed_at":"2022-04-07T18:15:34.000Z","size":2830,"stargazers_count":6,"open_issues_count":5,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-07T03:19:49.937Z","etag":null,"topics":["electron","electron-app","electron-application","logger"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/Syed-Umair.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}},"created_at":"2017-08-17T10:10:14.000Z","updated_at":"2022-12-24T12:19:09.000Z","dependencies_parsed_at":"2022-08-25T05:41:28.376Z","dependency_job_id":null,"html_url":"https://github.com/Syed-Umair/logger","commit_stats":null,"previous_names":[],"tags_count":65,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Syed-Umair%2Flogger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Syed-Umair%2Flogger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Syed-Umair%2Flogger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Syed-Umair%2Flogger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Syed-Umair","download_url":"https://codeload.github.com/Syed-Umair/logger/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246832468,"owners_count":20841172,"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":["electron","electron-app","electron-application","logger"],"created_at":"2024-08-01T11:00:52.319Z","updated_at":"2025-04-02T14:31:40.926Z","avatar_url":"https://github.com/Syed-Umair.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# logger-electron\n\nlogger-electron is a ease to use logger companion for electron applications.\n\n### Whats Special about this logger?\n  - Session based log collection.\n  - Automatic removal of logs older than EXPIRY time.\n  - Get logs.zip that can be used to submit feedback\n  - Integrated Bugsnag to get notified on errors.\n\n![Sample Log File Location](https://raw.githubusercontent.com/Syed-Umair/logger/master/ScreenShots/sample1.PNG)\n![Sample Log FileNames in some session folder](https://raw.githubusercontent.com/Syed-Umair/logger/master/ScreenShots/sample2.PNG)\n\n### Log Files location:\n  - %localappdata%/\u003c*appName*\u003e-logs/ for windows\n  - \u003cuser\u003e/library/Application Support/\u003c*appName*\u003e-logs/ for macos\n\n##### Note: \n\n  The appName is found if the package.json exists in the app root directory contains name parameter. If not found, default value electron-app is assigned that is electron-app-logs folder is used. \n\n### Installation\n\nInstall the logger-electron.\n\n```sh\n$ npm install logger-electron\n```\n\n### Getting Started\n\nCreate Instance:\n```sh\nvar logger = require(\"logger-electron\");\nlogger = new logger({\n    fileName : \"\u003ccustom fileName\u003e\", //optional, default = empty string\n    bugsnagKey : \"\u003capi Key\u003e\", //optional default = null\n    isWebview : \"\u003cboolean\u003e\", //optional default = false\n    domain : \"\u003cstring\u003e\" //optional default = null\n});\n// For each instance new log file is created.\n```\n\nExamples:\n\n```sh\nlogger = new logger({});\n// Creates log file based on the process type renderer or main.\n\nlogger = new logger({\n  fileName: \"customFileName\"\n});\n// Creates customFileName-processType.log file.\n\nlogger = new logger({\n  bugsnagKey : \"\u003capi Key\u003e\"\n});\n// Reports error to registered bugsnag api key.\n\nlogger = new logger({\n  isWebview : true, \n  domain = \"\u003cURL string\u003e\"\n});\n// If its webview errors are not notified using bugsnag if api-key passed.\n// URL string passed is added to the log FileName.  \n```\n\n### Methods\n\n##### setLogExpiry(logExpiry):\n```sh\nlogger.setLogExpiry(10);\n// Deletes logs older than 10 days\n// Maximum value is 60 days\n```\n\n##### disableLogging():\n```sh\nlogger.disableLogging();\n// Disables File Logging\n```\n\n##### enableLogging():\n```sh\nlogger.enableLogging();\n// Enables File Logging\n```\n\n##### pruneOldLogs():\n```sh\nlogger.pruneOldLogs().then((mesg)=\u003e{console.log(mesg)});\n// Returns promise\n// Manually trigger deletion of logs older than default 7 days or setLogExpiry(logExpiry) days\n```\n\n##### getLogArchive():\n```sh\nlogger.getLogArchive().then((path)=\u003e{console.log(path)});\n// Returns promise\n// On resolve, gives you the path of the logs.zip file.\n```\n\n##### clearLogArchive(path):\n```sh\nlogger.clearLogArchive(path);\n// Prunes log archive path passed\n```\n\n##### debug(data to be logged):\n```sh\nlogger.debug(\u003cstring\u003e/\u003cobject\u003e/\u003cany\u003e);\n```\n\n##### log(data to be logged):\n```sh\nlogger.log(\u003cstring\u003e/\u003cobject\u003e/\u003cany\u003e);\n```\n\n##### info(data to be logged):\n```sh\nlogger.info(\u003cstring\u003e/\u003cobject\u003e/\u003cany\u003e);\n```\n\n##### warn(data to be logged):\n```sh\nlogger.warn(\u003cstring\u003e/\u003cobject\u003e/\u003cany\u003e);\n```\n\n##### error(data to be logged):\n```sh\nlogger.error(\u003cstring\u003e/\u003cobject\u003e/\u003cany\u003e);\n//pass directly the error object to get better stack trace results in the bugsnag.\n```\n\n##### Including the below code, will enable logs to print in dev-tool's console:\n\n```sh\nlogger.logAPI.on(\"logging\", function (transport, level, msg, meta) {\n  console[level](msg);\n});\n```\n\n### Todos\n\n - Write MORE Tests\n - Integrate to travisCI\n - Add Improved bugsnag integration\n\nLicense\n----\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSyed-Umair%2Flogger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSyed-Umair%2Flogger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSyed-Umair%2Flogger/lists"}