ProductPromotion
Logo

Angular.JS

made by https://0x3d.site

GitHub - TALRACE/ngx-action-logger: Action Logger
Action Logger. Contribute to TALRACE/ngx-action-logger development by creating an account on GitHub.
Visit Site

GitHub - TALRACE/ngx-action-logger: Action Logger

GitHub - TALRACE/ngx-action-logger: Action Logger

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

More Resources
to explore the angular.

mail [email protected] to add your project or resources here 🔥.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory