{"id":15459192,"url":"https://github.com/arakiss/nexlog","last_synced_at":"2025-04-22T10:44:57.689Z","repository":{"id":254396618,"uuid":"846406192","full_name":"Arakiss/nexlog","owner":"Arakiss","description":"A simple and effective logging library for Next.js, compatible with server, browser, and edge environments.","archived":false,"fork":false,"pushed_at":"2024-08-26T15:19:45.000Z","size":80,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-16T04:34:22.899Z","etag":null,"topics":["bun-js","console-logging","edge-computing","environment-detection","logging","nextjs","serverless","typescript","zero-dependencies"],"latest_commit_sha":null,"homepage":"","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/Arakiss.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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":"2024-08-23T06:20:54.000Z","updated_at":"2025-02-21T15:12:05.000Z","dependencies_parsed_at":"2024-11-14T15:54:15.408Z","dependency_job_id":"2ba65c0f-e05e-4be9-b385-7917e61d87c1","html_url":"https://github.com/Arakiss/nexlog","commit_stats":{"total_commits":55,"total_committers":2,"mean_commits":27.5,"dds":"0.018181818181818188","last_synced_commit":"653a5a9811ea8fb2e873104e3ebb2564a34a025c"},"previous_names":["arakiss/nextlogger"],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Arakiss%2Fnexlog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Arakiss%2Fnexlog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Arakiss%2Fnexlog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Arakiss%2Fnexlog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Arakiss","download_url":"https://codeload.github.com/Arakiss/nexlog/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249259146,"owners_count":21239422,"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":["bun-js","console-logging","edge-computing","environment-detection","logging","nextjs","serverless","typescript","zero-dependencies"],"created_at":"2024-10-01T23:05:20.756Z","updated_at":"2025-04-16T16:31:51.461Z","avatar_url":"https://github.com/Arakiss.png","language":"TypeScript","funding_links":["https://github.com/sponsors/Arakiss"],"categories":[],"sub_categories":[],"readme":"# nexlog\n\nnexlog is a simple, effective, and zero-dependency logging library for Next.js, compatible with server, browser, and edge environments. It's distributed as TypeScript files for maximum flexibility and type safety.\n\n![CI/CD](https://github.com/Arakiss/nexlog/actions/workflows/ci-cd.yml/badge.svg)\n![npm version](https://img.shields.io/npm/v/nexlog.svg)\n![License](https://img.shields.io/npm/l/nexlog.svg)\n\n## Features\n\n- Environment-aware logging (Server, Browser, Edge)\n- Customizable log levels\n- Colored console output for server environments\n- Full TypeScript support\n- Lightweight and easy to use\n- Zero external dependencies\n- No side effects\n- Distributed as TypeScript files for maximum flexibility\n\n## Installation\n\n```bash\nnpm install nexlog\n# or\nyarn add nexlog\n# or\nbun add nexlog\n```\n\n## Configuration with Next.js\n\nTo use nexlog with Next.js, follow these steps:\n\n1. Install nexlog as shown above.\n\n2. Configure Next.js to transpile nexlog. In your `next.config.js` or `next.config.mjs`:\n\n```javascript\n/** @type {import('next').NextConfig} */\nconst nextConfig = {\n  transpilePackages: [\"nexlog\"],\n};\n\nexport default nextConfig;\n```\n\n3. Use the LoggerProvider in your root layout (e.g., in `app/layout.tsx`):\n\n```typescript\nimport { LoggerProvider } from 'nexlog/react';\n\nexport default function RootLayout({ children }: { children: React.ReactNode }) {\n  return (\n    \u003chtml lang=\"en\"\u003e\n      \u003cbody\u003e\n        \u003cLoggerProvider\u003e\n          {children}\n        \u003c/LoggerProvider\u003e\n      \u003c/body\u003e\n    \u003c/html\u003e\n  );\n}\n```\n\n4. In your components, use the `useLogger` hook:\n\n```typescript\n'use client';\nimport { useLogger } from 'nexlog/react';\n\nexport default function MyComponent() {\n  const logger = useLogger();\n  logger.info('MyComponent rendered');\n  return \u003cdiv\u003eMy Component\u003c/div\u003e;\n}\n```\n\n## Usage\n\n```typescript\nimport logger from 'nexlog';\n\n// Log messages\nlogger.info('This is an info message');\nlogger.warn('This is a warning', { additionalInfo: 'Some extra data' });\nlogger.error('An error occurred', { errorCode: 500 });\n```\n\nNote: The default export is an instance of the ConfigurableLogger class, pre-configured for the detected environment.\n\n### Output Example\n\nServer environment:\n```\n[INFO] This is an info message\n[WARN] This is a warning {\"additionalInfo\":\"Some extra data\"}\n[ERROR] An error occurred {\"errorCode\":500}\n```\n\nBrowser/Edge environment:\n```\n[INFO] This is an info message\n[WARN] This is a warning {\"additionalInfo\":\"Some extra data\"}\n[ERROR] An error occurred {\"errorCode\":500}\n```\n\n## API\n\n### Methods\n\n- `logger.trace(msg: string, meta?: object)`\n- `logger.debug(msg: string, meta?: object)`\n- `logger.info(msg: string, meta?: object)`\n- `logger.warn(msg: string, meta?: object)`\n- `logger.error(msg: string, meta?: object)`\n- `logger.fatal(msg: string, meta?: object)`\n- `logger.setLevel(level: LogLevel)`\n- `logger.getLevel(): LogLevel`\n- `logger.enable()`\n- `logger.disable()`\n- `logger.isEnabled(): boolean`\n- `logger.setSSROnly(ssrOnly: boolean)`\n\n### Types\n\n```typescript\ntype LogLevel = \"trace\" | \"debug\" | \"info\" | \"warn\" | \"error\" | \"fatal\";\n```\n\n## Configuration\n\nYou can configure the logger using the following methods:\n\n```typescript\n// Set the log level\nlogger.setLevel('debug');\n\n// Enable or disable logging\nlogger.enable();\nlogger.disable();\n\n// Set SSR-only mode\nlogger.setSSROnly(true);\n```\n\n## Environment Detection\n\nnexlog automatically detects the current environment (server, browser, or edge) and adjusts its output accordingly. You can also use helper functions for detection:\n\n```typescript\nimport { isServer, isNextEdgeRuntime } from 'nexlog';\n\nif (isServer) {\n  console.log('Running on server');\n} else if (isNextEdgeRuntime) {\n  console.log('Running on edge runtime');\n} else {\n  console.log('Running in browser');\n}\n```\n\n## Development\n\nTo install dependencies:\n\n```bash\nnpm install\n# or\nyarn install\n# or\nbun install\n```\n\nTo run tests:\n\n```bash\nnpm test\n# or\nyarn test\n# or\nbun test\n```\n\n## Contributing\n\nWhile I'm currently the sole developer of this project, I'm open to contributions. If you have suggestions or want to contribute, please feel free to open an issue or submit a pull request.\n\n## License\n\nThis project is licensed under the MIT License.\n\n## Support\n\nIf you find nexlog helpful, consider [sponsoring me](https://github.com/sponsors/Arakiss). Your support helps me maintain and improve this project.\n\n## FAQ\n\n### Does nexlog have any external dependencies?\n\nNo, nexlog is designed to be completely self-contained with zero external dependencies.\n\n### Does nexlog have any side effects?\n\nNo, nexlog is carefully designed to avoid any side effects. It doesn't modify global objects or interfere with other parts of your application.\n\n### Why is nexlog distributed as TypeScript files?\n\nDistributing nexlog as TypeScript files provides maximum flexibility for users. It allows for better tree-shaking, gives users full type information, and lets them compile the library according to their project's specific needs.\n\n### Why do I need to add 'use client' when using useLogger?\n\nThe `useLogger` hook is a React hook, and hooks can only be used in client components. Adding 'use client' at the beginning of the file tells Next.js that this component should be rendered on the client side.\n\n### Why do I need to configure Next.js to transpile nexlog?\n\nnexlog is distributed as TypeScript files to provide maximum flexibility and type safety. However, Next.js doesn't automatically transpile dependencies. By adding nexlog to the `transpilePackages` array in your Next.js configuration, you ensure that the TypeScript files are properly compiled for use in your Next.js application.\n\n### I'm getting a \"Module parse failed: Unexpected token\" error. How do I fix it?\n\nThis error typically occurs when Next.js is trying to parse the TypeScript files directly. To resolve this, make sure you've properly configured Next.js to transpile nexlog as described in the \"Configuration with Next.js\" section above.\n\n### The useLogger hook is not working. What might be the issue?\n\nIf you're encountering issues with the `useLogger` hook, ensure that:\n1. You've wrapped your application with the `LoggerProvider` in your root layout.\n2. You're using 'use client' directive in the file where you're using `useLogger`.\n3. You've properly configured Next.js to transpile nexlog.\n\nIf you're still having issues, please open an issue on the GitHub repository with details about your setup and the specific error you're encountering.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farakiss%2Fnexlog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farakiss%2Fnexlog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farakiss%2Fnexlog/lists"}