npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@talrace/ngx-action-logger

v0.0.2

Published

## Description

Downloads

7

Readme

ngx-action-logger

Description

Logger for Angular applications, capable of both outputting data to the console or sending data to elastic. After sending to the elastic, you can view the data (for example, in kibana), build custom charts, etc. There are two decorators - LogComponentLifeCycle and Log. LogComponentLifeCycle - used for component life cycle logging, Log - function logging. Also, the logger can be used anywhere using DI. It is possible to expand the logged data or use your own service for logging that expands or complements the functionality.

Installation

Add LoggerModule to your AppModule

...
import { appModuleInjector, LoggerModule } from 'ngx-action-logger';
...

@NgModule({
    ...
    imports: [
        ...
        LoggerModule.forRoot({
            sessionId: 'uuid',
            elasticOptions: { index: 'yourIndex', url: 'http://localhost:9200', username: 'elastic', password: '123456' }
        }),
        ...
    ],
    ...
})
export class AppModule {
    constructor(protected injector: Injector) {
        appModuleInjector(injector);
    }
}

LogComponentLifeCycle decorator

@LogComponentLifeCycle({ className: 'UsersComponent', hooks: ['ngOnInit', 'ngOnDestroy'], message: 'customMessage' })
@Component({
    selector: 'app-users',
    templateUrl: './users.component.html',
    styleUrls: ['./users.component.scss'],
    changeDetection: ChangeDetectionStrategy.OnPush
})
export class UsersComponent {}

Log decorator

@Log({ className: 'UsersComponent', message: 'customMessage' })
onCancel(): void {}

Kibana example

After successfully sending the data to elastic, you can view the data and build graphs in kibana. For this you need:

  1. Create new index patter (Stack Management -> Index patterns -> Create index pattern). Type your index name to the input and click "Next step". type your index name

Select time filter filed (index by default contains "timestamp" filed with date property type by default) and click "Create index pattern". select time filter filed

After some seconds you can see your created index pattern with all fields. created index pattern

  1. You can discover index data. Open "Discover" page in kibana. "Discover" page

Select your index pattern and research incoming data. Use search if needed used KQL. "Discover" data

  1. You can combine data views from any Kibana app into one dashboard and see everything in one place. Open "Dashboards" page in kibana. "Dashboards" data

Select "Create new dashboard". Create new dashboard

Add an existing or new object to this dashboard, click "Create new". Create new

Select "Go to Lens" or select visualization. Go to Lens

Drag any fields in left side and drop fields in center for display visualization. Drag any fields

Select any other Suggestions or change settings in right side. Select any Suggestions

Save your visualization and Add title and description. Save your visualization

Create new visualization if needed. Create new visualization if needed.

API

Logger module used API:

LoggerModule

  • forRoot - used for add module to your project (see example)

ConsoleLoggerService

Logger by default. Logger use this service when not set other service in config or not set config for elastic. All incoming data in log shown in console

ElasticLoggerService

Send data to elastic for logging. You can check data in kibana or added custom dashboard graphics, for example.

  • url - elastic url for send data

  • index - elastic index. Logger check index before send data, when index not exists - create index with typed properties

  • username - login for access to elastic

  • password - password for access to elastic

  • indexProperties? - custom mapping index properties (used DEFAULT_INDEX_PROPERTIES const when this property is empty)

  • chunkSize? - max chuck with elastic data (used 100 when this property is empty)

  • sendDataTimeout? - timeout between send data to elastic. Before send to elastic data is accumulated in a transaction (used 5000 milliseconds when this property is empty)

Decorators

LogComponentLifeCycle - life cycle decorator for components.

  • className? - custom class name for current component (by default used current class name, but in prod mode the class name is unreadable)

  • message? - custom message, empty by default

  • hooks? - component life cycle hooks for logging (if empty used DEFAULT_LOG_DECORATOR_LIFE_CYCLE_OPTIONS)

Log - logging decorator for functions

  • className? - custom class name for current class (by default used current class name, but in prod mode the class name is unreadable)

  • message? - custom message, empty by default

Injector

  • appModuleInjector - set or get app injector

  • clearInjector - clear app injector

Const

  • DEFAULT_OPTIONS - default options for logger, user in logger initialization

  • LOGGER_OPTIONS - injection token for logger options

  • DEFAULT_LOG_DECORATOR_LIFE_CYCLE_OPTIONS - default logger hooks for LogComponentLifeCycle. Used by default when not set any hook in LogComponentLifeCycle

  • DEFAULT_INDEX_PROPERTIES - json for create elastic index with typed properties