{"id":15640176,"url":"https://github.com/typicode/logan","last_synced_at":"2025-07-31T19:06:54.442Z","repository":{"id":11787167,"uuid":"14328766","full_name":"typicode/logan","owner":"typicode","description":"Mini template system for the console and colors","archived":false,"fork":false,"pushed_at":"2013-12-20T13:01:55.000Z","size":108,"stargazers_count":82,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-07-05T11:44:21.022Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://github.com/typicode","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/typicode.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":"2013-11-12T10:13:00.000Z","updated_at":"2025-03-27T07:32:40.000Z","dependencies_parsed_at":"2022-09-23T02:01:01.381Z","dependency_job_id":null,"html_url":"https://github.com/typicode/logan","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/typicode/logan","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typicode%2Flogan","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typicode%2Flogan/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typicode%2Flogan/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typicode%2Flogan/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/typicode","download_url":"https://codeload.github.com/typicode/logan/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typicode%2Flogan/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265527603,"owners_count":23782480,"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-10-03T11:31:55.659Z","updated_at":"2025-07-16T17:34:18.106Z","avatar_url":"https://github.com/typicode.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Logan\n\n![](http://i.imgur.com/xg4wt5j.png)\n\nLogan is a mini template system for the console and [colors](https://github.com/Marak/colors.js). \n\nIt allows to cleanly separate content from style and create beautiful logging functions.\n\n## Example\n\nLet's say you want to write a logging function that says hello.\n\n```javascript\n// Without Logan\nfunction hello(arg) {\n  console.log('Hello'.bold.green + ' : ' + arg.cyan);\n}\n\n// With Logan\nvar hello = logan.create('Hello : %', 'bold.green . cyan')\n\nhello('world');\n```\n\n![](http://i.imgur.com/4I6nDTp.png)\n\n## Usage\n\n```javascript\nvar logan = require('logan');\n```\n\n### set\n\nThis is the most useful method of logan. It lets you define all your templates in one place.\n\n```javascript\nlogan.set({\n  info: ['info : %', 'yellow'],\n  warn: ['warn : %', 'orange'],\n  omg : ['omg  : %', 'rainbow']\n});\n\nlogan.info('some info');\n```\n\nNotice how easy it is to see what all your logging functions will output.\n\nAlso, with ```set``` your module users can easily theme logs:\n\n```javascript\n// Overriding omg to be... more OMG!!!\nlogan.set({\n  omg: ['OMG : % !!!', 'red . . red']\n});\n```\n\n### create\n\nReturns a logging function.\n\n```javascript\nvar info = logan.create('info : %', 'yellow');\ninfo('some text');\n```\n\n### compile\n\nReturns a function which returns a string when called.\n\n```javascript\nvar info = logan.compile('info : %', 'yellow');\nconsole.log(info('some text'));\n```\n\n## Syntax\n\n* **%** is used for string replacement.\n* **{}** lets you define blocks.\n* **.** means default style.\n* styles can be chained (example: bold.underline.red).\n\n**{}** usage:\n\n```javascript\n// for example, instead of writing this:\nvar green = logan.create('some long green string', 'green green green green');\n\n// using {} you can write\nvar green = logan.create('{some long green string}', 'green');\n```\n\n## Configuration\n\nIf you want to suppress all output, during tests for example, just set ```silent``` to ```true```.\n\n```javascript\nlogan.set({'foo': ['foo', 'red']});\nlogan.silent = true;\nlogan.foo(); // No output\nlogan.silent = false;\nlogan.foo(): // will output 'foo'\n```\n\n## About the name\n\nSince there's a templating engine called [hogan](http://twitter.github.io/hogan.js/) and this one is about logging, it was called logan.\n\n## More\n\nIf you want to see how Logan can be used in another project, you can have a look at [ShoutJS](https://github.com/typicode/shoutjs).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftypicode%2Flogan","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftypicode%2Flogan","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftypicode%2Flogan/lists"}