Skip to content
This repository was archived by the owner on Jun 18, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions helpers/test.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ import { LoggerLevel } from '../projects/logger/src/lib/logger.config';
import { Fn, LogFn, TimerInfo } from '../projects/logger/src/lib/logger.interfaces';
import { TimerLog } from '../projects/logger/src/lib/decorators/timer.decorator';

interface HttpDebugInterface {
method: string;
url: string;
queryParams: string;
data: unknown;
body: unknown;
errorData: unknown;
}

// noinspection AngularMissingOrInvalidDeclarationInModule
@Component({ selector: 'lib-hello-test', template: '' })
export class MyTestComponent implements OnInit {
Expand Down Expand Up @@ -70,6 +79,17 @@ export class MyTestComponent implements OnInit {
return name;
}

@Group((options: Partial<HttpDebugInterface>) => MyTestComponent.getUrlInfo(options))
public hello(name: string): string {
this.logger.log('group is worked');
return name;
}

public static getUrlInfo({ method, url, queryParams }: Partial<HttpDebugInterface>): string {
const params: string = queryParams ? `?${queryParams}` : '';
return `[${method}] - ${url}${params}`;
}

@TimerLog('mock:ngOnInit')
public ngOnInit(): void {
this.hook = 'ngOnInit';
Expand Down
2 changes: 1 addition & 1 deletion projects/logger/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@angular-ru/logger",
"version": "1.4.0",
"version": "1.5.0",
"license": "MIT",
"homepage": "https://github.com/Angular-RU/angular-logger",
"repository": "https://github.com/Angular-RU/angular-logger",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ import { GroupLevel, LoggerLevel } from '../../logger.config';
import { groupDecoratorFactory } from './group.common';
import { Any, Callback, DecoratorMethod } from '../../logger.interfaces';

export function GroupCollapsed(
title: string | Callback<string>,
level: LoggerLevel = LoggerLevel.INFO
): DecoratorMethod {
export function GroupCollapsed(title: string | Callback<Any>, level: LoggerLevel = LoggerLevel.INFO): DecoratorMethod {
return (_target: Type<unknown>, _key: string, descriptor: PropertyDescriptor): PropertyDescriptor => {
const method: Callback = descriptor.value;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { GroupLevel, LoggerLevel } from '../../logger.config';
import { groupDecoratorFactory } from './group.common';
import { Any, Callback, DecoratorMethod } from '../../logger.interfaces';

export function Group(title: string | Callback<string>, level: LoggerLevel = LoggerLevel.INFO): DecoratorMethod {
export function Group(title: string | Callback<Any>, level: LoggerLevel = LoggerLevel.INFO): DecoratorMethod {
return (_target: Type<unknown>, _key: string, descriptor: PropertyDescriptor): PropertyDescriptor => {
const method: Callback = descriptor.value;

Expand Down