Home > @imqueue/rpc > logged

logged() function

Creates a @logged() method decorator that wraps the decorated method in a try/catch and logs any error it throws. The logger is resolved in this order: an explicitly passed logger, then a logger defined on the instance or on the class, and finally the global console. By default the error is re-thrown after being logged; pass { doNotThrow: true } to swallow it. The returned decorator is dual-mode: it works both as a standard (TC39) and as a legacy method decorator.

Signature:

export declare function logged(options?: ILogger | LoggedDecoratorOptions): any;

Parameters

Parameter

Type

Description

options

ILogger | LoggedDecoratorOptions

(Optional) a logger to use, or the logged-decorator options {Function} - a dual-mode method decorator

Returns:

any