Maurizio Vitale 1fa81962a0
👽 Angular 14 rebase 👽 (#7769)
* fix after rebase

* new release strategy for ng next

Signed-off-by: eromano <eugenioromano16@gmail.com>

* peer dep

Signed-off-by: eromano <eugenioromano16@gmail.com>

* Angular 14

fix unit test and storybook

Signed-off-by: eromano <eugenioromano16@gmail.com>

fix after rebase

Signed-off-by: eromano <eugenioromano16@gmail.com>

update pkg.json

Signed-off-by: eromano <eugenioromano16@gmail.com>

missing dep

Signed-off-by: eromano <eugenioromano16@gmail.com>

Fix mistake and missing code

Dream....build only affected libs

Add utility run commands

* Use nx command to run affected tests

* Fix nx test core

fix content tests

Run unit with watch false

core test fixes

reduce test warnings

Fix process cloud unit

Fix adf unit test

Fix lint process cloud

Disable lint next line

Use right core path

Fix insights unit

fix linting insights

Fix process-services unit

fix the extensions test report

fix test warnings

Fix content unit

Fix bunch of content unit

* Produce an adf alpha of 14

* hopefully fixing the content

* Push back the npm publish

* Remove flaky unit

* Fix linting

* Make the branch as root

* Get rid of angualar13

* Remove the travis depth

* Fixing version for npm

* Enabling cache for unit and build

* Fix scss for core and paths

Copy i18 and asset by using ng-packager

Export the theming alias and fix path

Use ng-package to copy assets process-services-cloud

Use ng-package to copy assets process-services

Use ng-package to copy assets content-services

Use ng-package to copy assets insights

* feat: fix api secondary entry point

* fix storybook rebase

* Move dist under dist/libs from lib/dist

* Fix the webstyle

* Use only necessary nrwl deps and improve lint

* Fix unit for libs

* Convert lint.sh to targets - improve performance

* Use latest of angular

* Align alfresco-js-api

Signed-off-by: eromano <eugenioromano16@gmail.com>
Co-authored-by: eromano <eugenioromano16@gmail.com>
Co-authored-by: Mikolaj Serwicki <mikolaj.serwicki@hyland.com>
Co-authored-by: Tomasz <tomasz.gnyp@hyland.com>
2022-08-25 10:50:30 +01:00

5.1 KiB

Title, Added, Status, Last reviewed
Title Added Status Last reviewed
Log Service v2.0.0 Active 2018-06-08

Log Service

Provides log functionality.

Basic Usage

app.component.ts

import { LogService } from '@alfresco/adf-core';

@Component({...})
export class AppComponent {

    constructor(logService: LogService) {
    }
    
    myMethod(){
      this.logService.error('My error');
      this.logService.trace('My trace')
      this.logService.debug('My debug')
      this.logService.info('My info')
      this.logService.warn('My warn')
    }
    
}
import { LogService } from '@alfresco/adf-core';

@Component({...})
export class AppComponent {

    constructor(logService: LogService, myIntegrationService: MyIntegrationService)) {
        logService.onMessage.subscribe((message) => {
               myIntegrationService.send(message.text,message.type);
         });
    }
}

Class members

Methods

  • assert(test?: boolean, message?: string, optionalParams: any[])
    Logs a message if a boolean test fails.
    • test: boolean - (Optional) Test value (typically a boolean expression)
    • message: string - (Optional) Message to show if test is false
    • optionalParams: any[] - Interpolation values for the message in "printf" format
  • debug(message?: any, optionalParams: any[])
    Logs a message at the "DEBUG" level.
    • message: any - (Optional) Message to log
    • optionalParams: any[] - Interpolation values for the message in "printf" format
  • error(message?: any, optionalParams: any[])
    Logs a message at the "ERROR" level.
    • message: any - (Optional) Message to log
    • optionalParams: any[] - Interpolation values for the message in "printf" format
  • getLogLevel(level: string): LogLevelsEnum
    Converts a log level name string into its numeric equivalent.
    • level: string - Level name
    • Returns LogLevelsEnum - Numeric log level
  • group(groupTitle?: string, optionalParams: any[])
    Starts an indented group of log messages.
    • groupTitle: string - (Optional) Title shown at the start of the group
    • optionalParams: any[] - Interpolation values for the title in "printf" format
  • groupEnd()
    Ends a indented group of log messages.
  • info(message?: any, optionalParams: any[])
    Logs a message at the "INFO" level.
    • message: any - (Optional) Message to log
    • optionalParams: any[] - Interpolation values for the message in "printf" format
  • log(message?: any, optionalParams: any[])
    Logs a message at any level from "TRACE" upwards.
    • message: any - (Optional) Message to log
    • optionalParams: any[] - Interpolation values for the message in "printf" format
  • messageBus(text: string, logLevel: string)
    Triggers notification callback for log messages.
    • text: string - Message text
    • logLevel: string - Log level for the message
  • trace(message?: any, optionalParams: any[])
    Logs a message at the "TRACE" level.
    • message: any - (Optional) Message to log
    • optionalParams: any[] - Interpolation values for the message in "printf" format
  • warn(message?: any, optionalParams: any[])
    Logs a message at the "WARN" level.
    • message: any - (Optional) Message to log
    • optionalParams: any[] - Interpolation values for the message in "printf" format

Details

Log levels

There are 6 levels of logs that you can use:

Name Level
TRACE 5
DEBUG 4
INFO 3
WARN 2
ERROR 1
SILENT 0

You can set the default log level using the logLevel property in app.config.json. The factory setting for this property is TRACE.

For example, you can set the default log level to WARNING as follows:

app.config.json

{
    "logLevel": "WARN" 
}

Log message bus

The log service also provides an Observable called _onMessage_ that you can subscribe to if you want to receive all the log messages. The message object passed as a parameter to the onMessage handler has the following format:

{
    text: "Message log text"
    type: "ERROR|DEBUG|INFO|LOG|TRACE|WARN|ASSERT"
}

Using the log to feed analytics

You can pass the log output to an analytics system to collect error and assertion data from apps as they run. This can help you spot which problems users are running into most often and the situations in which they occur. See the tutorial about integrating the log service with analytics on the Alfresco Community site for further information.