{"id":18421164,"url":"https://github.com/ud-ud/simple-logger","last_synced_at":"2025-04-13T11:24:01.782Z","repository":{"id":83176321,"uuid":"132465110","full_name":"UD-UD/simple-logger","owner":"UD-UD","description":"Simple logger with module-specific instances and log format strings","archived":false,"fork":false,"pushed_at":"2018-05-09T11:28:06.000Z","size":95,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-16T07:17:51.480Z","etag":null,"topics":["logging"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/UD-UD.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":"2018-05-07T13:32:40.000Z","updated_at":"2018-10-09T15:44:49.000Z","dependencies_parsed_at":null,"dependency_job_id":"31a771f7-f7bf-44e4-9cdd-b1d5ece63aa2","html_url":"https://github.com/UD-UD/simple-logger","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UD-UD%2Fsimple-logger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UD-UD%2Fsimple-logger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UD-UD%2Fsimple-logger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UD-UD%2Fsimple-logger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/UD-UD","download_url":"https://codeload.github.com/UD-UD/simple-logger/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248704183,"owners_count":21148312,"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":["logging"],"created_at":"2024-11-06T04:24:37.344Z","updated_at":"2025-04-13T11:24:01.758Z","avatar_url":"https://github.com/UD-UD.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simple Logger\n\n## API Usage\n\n```js\n\nimport { SimpleLogger, LogLevel } from 'simple-logger';\n\nconst l = new SimpleLogger('testModule');\n\n// Log methods\nl.log('message'); // 10:40:50::testModule::LOG:: message\nl.debug('message'); // 10:40:50::testModule::DEBUG:: message\nl.warn('message'); // 10:40:50::testModule::WARN:: message\nl.error('message'); // 10:40:50::testModule::ERROR:: message\n\n// Change format string\nl.setFormatString('Module is: {module} - {message} - at time {HH}:{MM}:{ss}');\n\nl.debug('Hello world'); // Module is: testModule - Hello world - at time 11:48:57\n\n// Change log level \nSimpleLogger.setLogLevel(LogLevel.warn);\n\nl.debug('Hello world'); // No log\n\n// Reset log level\nSimpleLogger.resetLogLevel();\n\n```\n\nDetails of the string which can be passed into `setFormatString` is described below.\n\n### Format string specs\n\nWe are using two libraries called `string-format` and `dateformat`.\n\n#### [string-format](https://github.com/davidchambers/string-format) -\n\nWe use this for the template string syntax. It allows quite a few syntaxes, but we are using the simple object destructuring syntax, which is shown in the first example [here](https://github.com/davidchambers/string-format#string-format).\n\nTo explain it simply, the formatting string looks like `\"Hello Mr.{key1} - Welcome to {key2}\"` and the values of this keys will be replaced with those from the formatting object. Invalid keys will create empty replacement string.\n\nWe pass in a formatting object with these keys:\n\n1. `module` - Module name, passed in the Logger constructor.\n2. `message` - String passed in log / warn / error methods.\n3. `logLevel` - Log level in upper case, eg. DEBUG.\n4. Timestamp related keys - Documented below\n\nDefault format string is `'{HH}:{MM}:{ss}::{module}::{logLevel}:: {message}'`\n\n#### [dateformat](https://www.npmjs.com/package/dateformat) -\n\nUsing this library, we create many time related keys, which are mostly equivalent to what is documented in [mask options](https://www.npmjs.com/package/dateformat#mask-options) and [named formats](https://www.npmjs.com/package/dateformat#named-formats). \n\nWhat is slightly different from the above documentation is that we don't support `N`, `o`, `S`, `Z` and `UTC:` as they act as modifiers and don't make much sense as individual keys.\n\nSome examples of supported date format strings are:\n\n1. `\"{default}\"` - Sat Jun 09 2007 17:46:21\n2. `\"{HH}:{MM}:{ss}\"` - 11:48:57\n3. `\"{shortDate} ({W}th week of the year)\"` - 6/9/07 (34th week of the year)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fud-ud%2Fsimple-logger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fud-ud%2Fsimple-logger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fud-ud%2Fsimple-logger/lists"}