A Svelte component for displaying and streaming log files with syntax highlighting, search functionality, and more.
npm install @zwidekalanga/svelte-lazylog
or
yarn add @zwidekalanga/svelte-lazylog
<script>
    import { LazyLog } from '@zwidekalanga/svelte-lazylog';
</script>
<LazyLog
    text="This is a sample log text\nWith multiple lines\nAnd more content"
    height="400px"
    enableLineNumbers={true}
    enableSearch={true}
/>
<script>
    import { LazyLog } from '@zwidekalanga/svelte-lazylog';
</script>
<LazyLog
    url="wss://api.example.com/logs/stream"
    websocket={true}
    follow={true}
    height="600px"
    enableSearch={true}
/>
<script>
    import { LazyLog } from '@zwidekalanga/svelte-lazylog';
</script>
<LazyLog
    url="https://api.example.com/logs/stream"
    eventsource={true}
    follow={true}
    height="600px"
    enableSearch={true}
/>
| Prop | Type | Default | Description | 
|---|---|---|---|
| text | string | undefined | String containing log text to display | 
| url | string | undefined | URL from which to fetch log content | 
| height | string/number | 'auto' | Height of the component | 
| width | string/number | 'auto' | Width of the component | 
| enableSearch | boolean | false | Enable the search functionality | 
| enableLineNumbers | boolean | true | Show line numbers | 
| caseInsensitive | boolean | false | Enable case insensitive search | 
| follow | boolean | false | Auto-scroll to the bottom when new content is added | 
| websocket | boolean | false | Specify that URL is a WebSocket URL | 
| eventsource | boolean | false | Specify that URL is an EventSource URL | 
| websocketOptions | object | {} | Configuration options for WebSocket connection | 
| eventsourceOptions | object | {} | Configuration options for EventSource connection | 
| highlight | number/number[] | [] | Line number(s) to highlight | 
For a full list of props, see the type definitions in the source code.
The package includes several test suites:
# Run unit tests
yarn test:unit
# Run end-to-end tests
yarn test:e2e
# Run package structure tests
yarn test:package
# Run all tests
yarn test
The package structure tests verify that the library can be properly imported by consumer projects.
This project uses a comprehensive code coverage setup that combines coverage from both unit tests and E2E tests:
merge-coverage.js) combines coverage data from both sourcesTo run tests with coverage:
# Run unit tests with coverage
yarn test:unit:coverage
# Run E2E tests with coverage
yarn test:e2e:coverage
# Merge coverage reports (after running both test suites with coverage)
node scripts/merge-coverage.js
The merged coverage report can be found at coverage/combined/index.html.
We use Changesets for versioning and publishing, and follow the Luijten branching strategy for library development.
main branch is reserved for the next major version development0.x, 1.x, 2.x)For non-breaking changes:
0.x)yarn changeset to create a changeset fileFor breaking changes:
mainyarn changeset major to create a changeset file for a major version bumpmainOur CI/CD pipeline will:
mainFor more details, see the Changesets documentation and the CI/CD Pipeline documentation.
Check out the examples in the Storybook:
# Run storybook locally
yarn storybook
Supports all modern browsers including:
This library includes TypeScript type definitions for all components and props.
import { LazyLog } from '@zwidekalanga/svelte-lazylog';
import type { LazyLogProps } from '@zwidekalanga/svelte-lazylog';
const props: LazyLogProps = {
    text: 'Sample log content',
    enableSearch: true
};
Additional documentation is available in the docs directory:
MIT