{"id":20183248,"url":"https://github.com/martonlederer/houston","last_synced_at":"2025-04-10T05:24:56.308Z","repository":{"id":62421420,"uuid":"269710580","full_name":"martonlederer/Houston","owner":"martonlederer","description":"An advanced Deno logger, like Winston for Nodejs, with no dependencies","archived":false,"fork":false,"pushed_at":"2020-10-16T06:53:28.000Z","size":124,"stargazers_count":13,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-24T06:45:28.351Z","etag":null,"topics":["deno","javascript","js","node","npm","ts","typescript"],"latest_commit_sha":null,"homepage":"https://nest.land/package/Houston","language":"TypeScript","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/martonlederer.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":"2020-06-05T16:55:32.000Z","updated_at":"2024-11-14T05:12:22.000Z","dependencies_parsed_at":"2022-11-01T17:31:18.141Z","dependency_job_id":null,"html_url":"https://github.com/martonlederer/Houston","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martonlederer%2FHouston","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martonlederer%2FHouston/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martonlederer%2FHouston/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martonlederer%2FHouston/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/martonlederer","download_url":"https://codeload.github.com/martonlederer/Houston/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248161897,"owners_count":21057669,"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":["deno","javascript","js","node","npm","ts","typescript"],"created_at":"2024-11-14T02:44:41.563Z","updated_at":"2025-04-10T05:24:56.283Z","avatar_url":"https://github.com/martonlederer.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Houston\n[![nest badge](https://nest.land/badge.svg)](https://nest.land/package/Houston)\nAn advanced [Deno](https://deno.land) logger, with no dependencies.\n\n## Usage\nYou can create really simple or very advanced and complicated, informative logs with Houston.\n\n### Importing the module\n```ts\n//you can import all required types, etc. from the mod.ts\nimport { Houston } from 'https://x.nest.land/Houston@\u003cVERSION\u003e/mod.ts'\n```\n\n### Creating a basic logger\nFor this you will also need to import the `ConsoleTransport` [transport](#transports) from `mod.ts`\n```ts\nconst Logger = new Houston([\n\n  new ConsoleTransport()\n\n])\n```\nHere, we are basically creating a new logger for our project and initializing a new transport, a `ConsoleTransport`. You can read more about transports [here](#transports).\n\nIf you want to log something, you can easily do it depending on the level of your log:\n```ts\n//logging an info\nLogger.log(LogLevel.Info, 'This is an info')\n\n//logging a successful action\nLogger.log(LogLevel.Success, 'This is a success notice')\n\n//logging a warning\nLogger.log(LogLevel.Warning, 'This is a warning')\n\n//logging an error\nLogger.log(LogLevel.Error, 'This is an error')\n```\n\nor if you want to use a shorter form:\n\n```ts\nLogger.info('Info')\nLogger.success('Success')\nLogger.warning('Warning')\nLogger.error('Error')\n```\n\n## API\nAs explained above, we can use the `Houston` instance to create a new logger. You can read about it's configuration below.\n\n### Transports\nTransports are different methods of logging. You can add them to your logger by including one when initializing\n\n|   Transport name       |   Description |\n|------------------------|---------------|\n|   ConsoleTransport     |  This transport will log the desired messages to the command line, with additional options   |\n|   FileTransport        |  This transport will save your logs in a file    |\n|   WebTransport [W.I.P] |  This transport will send `PUT` requests containing your logs, to save on an external server  |\n\n#### Using `FileTransport`\nWhen you're using a FileTransport, an additional param is required to operate, the `logFolder` param.\n\nYou can use it like this:\n```ts\nconst Logger = new Houston([\n\n  new ConsoleTransport(),\n  new FileTransport('/home/marton/Downloads/logs')\n\n])\n```\nThis will save log files to the desired folder. The file extension depends on the log format (json or text).\n***Make sure to add the `--allow-write` and `--allow-read` flags when running your code, so Houston can access the log files.***\n\n### Config\nThe config is a set of custom options that modify the way your logs look. You can also use them with the transports, when adding one to the `Houston` instance\n\nAll the required types can be imported from `mod.ts`\n\nA full config object with all properties looks like this:\n```ts\n{\n\n    format: Format.text,\n    prefix: new TimePrefix(),\n    logLevelDisplay: LogLevelDisplay.Text,\n    logColors: {\n    \n        [LogLevel.Info]: Color.White,\n        [LogLevel.Success]: Color.Green,\n        [LogLevel.Warning]: Color.Yellow,\n        [LogLevel.Error]: Color.Red\n    \n    }\n\n}\n```\n\n#### `format: Format`\nThe format of the logs. Can be `text` or `json`\n\n`format: Format.json`\n\n#### `prefix: Prefix`\nThe prefix of your logs. Can be `TimePrefix` (prints the time), `TextPrefix` (a custom prefix by you) or `NoPrefix` (no prefix before logs)\n\nYou can also create your own `Prefix` implementation by importing `Prefix` from `mod.ts` and extending it.\n\n###### Modifying the `TimePrefix` date format\nYou can set the used time format for the `TimePrefix` to `TimeFormat.American` or `TimeFormat.European`\n\n`prefix: new TimePrefix(TimeFormat.American)`\n\n###### The `TextPrefix` prefix\nYou can apply a custom text like this:\n\n`prefix: new TextPrefix('Your prefix')`\n\n#### `logLevelDisplay: LogLevelDisplay`\nYou can customize what to display before the log message. This can be `LogLevelDisplay.Text` (prints the level of the log), `LogLevelDisplay.Icon` (prints an icon) or `LogLevelDisplay.Hidden` (no log level displaying).\n\n`LogLevelDisplay.Icon`\n\n#### `logColors: Record\u003cLogLevel, Color\u003e`\nThe colors of the different log levels. All fields are required, if you want to change one\n\n```ts\nlogColors: {\n\n    [LogLevel.Info]: Color.White,\n    [LogLevel.Success]: Color.Green,\n    [LogLevel.Warning]: Color.Yellow,\n    [LogLevel.Error]: Color.Red\n\n}\n```\n\n### Passing config to transports\n```ts\nconst Logger = new Houston([\n\n  new ConsoleTransport(\n\n    //adding log levels\n    [LogLevel.Info, LogLevel.Success, LogLevel.Warning, LogLevel.Error],\n    \n    //passing a config\n    { logLevelDisplay: LogLevelDisplay.Icon }\n  \n  )\n\n])\n```\nIf you don't pass a config to the transport, it will use the default config, determinated by the `Houston` instance\n\n## Screenshots\n`LogLevelDisplay.Icon`\n\n![withIcons](./screenshots/logs_with_icons.png)\n\n`LogLevelDisplay.Text`\n\n![withLabels](./screenshots/logs_with_labels.png)\n\nCustom colors\n\n![customColors](./screenshots/custom_colors.png)\n\n`new TextPrefix('Custom prefix')`\n\n![customPrefix](./screenshots/custom_prefix.png)\n\n`Format.json`\n\n![format](./screenshots/json_format.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmartonlederer%2Fhouston","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmartonlederer%2Fhouston","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmartonlederer%2Fhouston/lists"}