@polywrap/logger-plugin-js
Advanced tools
Comparing version
@@ -1,11 +0,11 @@ | ||
import { Module, Input_log, Logger_LogLevel } from "./wrap"; | ||
import { Module, Args_log, Logger_LogLevel } from "./wrap"; | ||
import { PluginFactory } from "@polywrap/core-js"; | ||
export declare type LogFunc = (level: Logger_LogLevel, message: string) => boolean; | ||
export interface LoggerPluginConfig extends Record<string, unknown> { | ||
export interface LoggerPluginConfig { | ||
logFunc?: LogFunc; | ||
} | ||
export declare class LoggerPlugin extends Module<LoggerPluginConfig> { | ||
log(input: Input_log): boolean; | ||
log(args: Args_log): boolean; | ||
} | ||
export declare const loggerPlugin: PluginFactory<LoggerPluginConfig>; | ||
export declare const plugin: PluginFactory<LoggerPluginConfig>; |
@@ -23,25 +23,25 @@ "use strict"; | ||
} | ||
LoggerPlugin.prototype.log = function (input) { | ||
LoggerPlugin.prototype.log = function (args) { | ||
if (this.config.logFunc) { | ||
return this.config.logFunc(input.level, input.message); | ||
return this.config.logFunc(args.level, args.message); | ||
} | ||
switch (input.level) { | ||
switch (args.level) { | ||
case "DEBUG": | ||
case wrap_1.Logger_LogLevelEnum.DEBUG: | ||
console.debug(input.message); | ||
console.debug(args.message); | ||
break; | ||
case "WARN": | ||
case wrap_1.Logger_LogLevelEnum.WARN: | ||
console.warn(input.message); | ||
console.warn(args.message); | ||
break; | ||
case "ERROR": | ||
case wrap_1.Logger_LogLevelEnum.ERROR: | ||
console.error(input.message); | ||
console.error(args.message); | ||
break; | ||
case "INFO": | ||
case wrap_1.Logger_LogLevelEnum.INFO: | ||
console.log(input.message); | ||
console.log(args.message); | ||
break; | ||
default: | ||
console.log(input.message); | ||
console.log(args.message); | ||
} | ||
@@ -53,5 +53,5 @@ return true; | ||
exports.LoggerPlugin = LoggerPlugin; | ||
exports.loggerPlugin = function (opts) { | ||
exports.loggerPlugin = function (config) { | ||
return { | ||
factory: function () { return new LoggerPlugin(opts); }, | ||
factory: function () { return new LoggerPlugin(config); }, | ||
manifest: wrap_1.manifest, | ||
@@ -58,0 +58,0 @@ }; |
@@ -10,5 +10,5 @@ { | ||
"uri": "ens/logger.core.polywrap.eth", | ||
"schema": "../../../core-interfaces/logger/src/query.graphql" | ||
"schema": "../../../core-interfaces/logger/src/schema.graphql" | ||
} | ||
] | ||
} |
import * as Types from "./types"; | ||
import { Client, PluginModule, MaybeAsync } from "@polywrap/core-js"; | ||
export interface Input_log extends Record<string, unknown> { | ||
export interface Args_log extends Record<string, unknown> { | ||
level: Types.Logger_LogLevel; | ||
message: Types.String; | ||
} | ||
export declare abstract class Module<TConfig extends Record<string, unknown>> extends PluginModule<TConfig> { | ||
abstract log(input: Input_log, client: Client): MaybeAsync<Types.Boolean>; | ||
export declare abstract class Module<TConfig> extends PluginModule<TConfig> { | ||
abstract log(args: Args_log, client: Client): MaybeAsync<Types.Boolean>; | ||
} |
@@ -25,3 +25,3 @@ import * as Types from "./"; | ||
export declare type Logger_LogLevel = Logger_LogLevelEnum | Logger_LogLevelString; | ||
interface Logger_Module_Input_log extends Record<string, unknown> { | ||
interface Logger_Module_Args_log extends Record<string, unknown> { | ||
level: Types.Logger_LogLevel; | ||
@@ -31,4 +31,4 @@ message: Types.String; | ||
export declare const Logger_Module: { | ||
log: (input: Logger_Module_Input_log, client: Client) => Promise<InvokeResult<Types.Boolean>>; | ||
log: (args: Logger_Module_Args_log, client: Client) => Promise<InvokeResult<Types.Boolean>>; | ||
}; | ||
export {}; |
@@ -59,3 +59,3 @@ "use strict"; | ||
exports.Logger_Module = { | ||
log: function (input, client) { return __awaiter(void 0, void 0, void 0, function () { | ||
log: function (args, client) { return __awaiter(void 0, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
@@ -65,3 +65,3 @@ return [2 /*return*/, client.invoke({ | ||
method: "log", | ||
input: input | ||
args: args | ||
})]; | ||
@@ -68,0 +68,0 @@ }); |
@@ -12,3 +12,3 @@ { | ||
], | ||
"version": "0.0.1-prealpha.89", | ||
"version": "0.0.1-prealpha.90", | ||
"main": "build/index.js", | ||
@@ -24,6 +24,6 @@ "scripts": { | ||
"dependencies": { | ||
"@polywrap/core-js": "0.0.1-prealpha.89" | ||
"@polywrap/core-js": "0.0.1-prealpha.90" | ||
}, | ||
"devDependencies": { | ||
"@polywrap/client-js": "0.0.1-prealpha.89", | ||
"@polywrap/client-js": "0.0.1-prealpha.90", | ||
"@types/jest": "26.0.8", | ||
@@ -37,3 +37,3 @@ "@types/prettier": "2.6.0", | ||
}, | ||
"gitHead": "26f0e513b94565f36c02acfd4cd5fb1b842413cb", | ||
"gitHead": "835cfa1d13cf7f0d3fb5796112d82acd466c7bbb", | ||
"publishConfig": { | ||
@@ -40,0 +40,0 @@ "access": "public" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
19867
-0.41%+ Added
+ Added
+ Added
- Removed
- Removed
- Removed