Skip to content

Commit

Permalink
Add log filter
Browse files Browse the repository at this point in the history
  • Loading branch information
maksim.zhemerenko committed Feb 21, 2024
1 parent 9a146be commit ea6761c
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 52 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/gradle-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v3
with:
node-version: '20.x'
node-version: '21.x'
registry-url: 'https://registry.npmjs.org'
- run: yarn && yarn build
- run: yarn publish
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20
21
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@spryrocks/capacitor-ionic-core-plugin",
"version": "5.7.0-alpha.0",
"version": "5.8.0-alpha.0",
"description": "Ionic plugin core capacitor",
"main": "dist/plugin.cjs.js",
"module": "dist/esm/index.js",
Expand All @@ -26,7 +26,7 @@
"compile": "tsc --noEmit"
},
"dependencies": {
"@spryrocks/logger-plugin": "^0.1.15-alpha.1"
"@spryrocks/logger-plugin": "^0.1.16-alpha.1"
},
"peerDependencies": {
"@capacitor/core": "^5.4.0"
Expand Down
44 changes: 27 additions & 17 deletions src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import {
import {
ErrorLevel,
ILoggerFactory,
ILoggerFilters,
LoggerFilters,
LogLevel,
LogParams,
MultipleNotifiers,
Expand All @@ -32,6 +34,7 @@ type LogEvent = {

export interface ICapacitorPlugin {
get logObserver(): ILoggerObserver;
get logFilters(): ILoggerFilters;
}

export type PluginOptions<TDefinitions extends IDefinitions> = {
Expand All @@ -56,6 +59,8 @@ export abstract class CapacitorPlugin<

private readonly _loggerFactory: ILoggerFactory<GlobalData>;

private readonly _logFilters = new LoggerFilters();

protected abstract readonly mappers: TMappers;

// noinspection TypeScriptAbstractClassConstructorCanBeMadeProtected
Expand Down Expand Up @@ -136,6 +141,7 @@ export abstract class CapacitorPlugin<
) {
try {
this.proxy.addListener(name, (event) => {
// eslint-disable-next-line no-console
console.log('CapacitorPlugin', 'event received', name, event);
listener(event as TListener);
});
Expand Down Expand Up @@ -164,23 +170,23 @@ export abstract class CapacitorPlugin<
}

private processLogEventReceived(event: LogEvent) {
this._logNotifiers.notify(
prepareLogData({
data: {
tag: event.tag,
message: event.message,
params: event.params,
level: event.level,
error: undefined,
errorLevel: ErrorLevel.Medium,
},
globalData: {
plugin: this.options.pluginLogName,
action: event.action,
isNative: true,
},
}),
);
const data = prepareLogData({
data: {
tag: event.tag,
message: event.message,
params: event.params,
level: event.level,
error: undefined,
errorLevel: ErrorLevel.Medium,
},
globalData: {
plugin: this.options.pluginLogName,
action: event.action,
isNative: true,
},
});
if (!this._logFilters.test(data)) return;
this._logNotifiers.notify(data);
}

// private isPluginAvailableInCapacitor() {
Expand All @@ -205,6 +211,10 @@ export abstract class CapacitorPlugin<
return this._logObserver;
}

public get logFilters(): ILoggerFilters {
return this._logFilters;
}

public get proxy() {
return this.options.proxy;
}
Expand Down
62 changes: 31 additions & 31 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -129,47 +129,47 @@
eslint-plugin-import "^2.28.1"
eslint-plugin-prettier "^5.0.0"

"@spryrocks/logger-core@^0.1.15-alpha.0":
version "0.1.15-alpha.0"
resolved "https://registry.yarnpkg.com/@spryrocks/logger-core/-/logger-core-0.1.15-alpha.0.tgz#c8c8f8f802ace92683e930b2918587bd30bb61ba"
integrity sha512-B+MfnTVMg8XsShJOLnXhJvmSc5/26tHRDyUvzfuw4MsAS4ME8vZuU/+tcyG/m+H8PbRDv5CE9Qmg0dwUFlk4EQ==
"@spryrocks/logger-core@^0.1.16-alpha.0":
version "0.1.16-alpha.0"
resolved "https://registry.yarnpkg.com/@spryrocks/logger-core/-/logger-core-0.1.16-alpha.0.tgz#184c9c285b50f80faeea687ba58d1713f126b5b2"
integrity sha512-LyNCmNFF++//9W2cxXzzQuJfbqHeSKUsGZT9253UD18yTeZYgmoPjpetFDy12UJVzNCjKVAV1gao3zBY4pDh0g==

"@spryrocks/logger-observer@^0.1.15-alpha.0":
version "0.1.15-alpha.0"
resolved "https://registry.yarnpkg.com/@spryrocks/logger-observer/-/logger-observer-0.1.15-alpha.0.tgz#9b406ef3e187a728fa867ffb770c39f32316c3d8"
integrity sha512-fz6Ls4KZRL2ZasrnTY8223R7KIjZ7pyy8W9HduwdY1jprgg13+qvGe52GFHDionA6pYeaYc8J1/rZ5wjYrvvUA==
"@spryrocks/logger-observer@^0.1.16-alpha.0":
version "0.1.16-alpha.0"
resolved "https://registry.yarnpkg.com/@spryrocks/logger-observer/-/logger-observer-0.1.16-alpha.0.tgz#34360d3a51fee978027c9b239e3014b0e2a44817"
integrity sha512-P8I4QJXQu5Hn4zdGfsUa1PqMEBNeFtEWB4X9UwqEZip8SGY4ovbk7VgguxALibFVW3jcahNrN3e9kkcKqBqG4Q==
dependencies:
"@spryrocks/logger-core" "^0.1.15-alpha.0"
"@spryrocks/logger-core" "^0.1.16-alpha.0"

"@spryrocks/logger-plugin-core@^0.1.15-alpha.0":
version "0.1.15-alpha.0"
resolved "https://registry.yarnpkg.com/@spryrocks/logger-plugin-core/-/logger-plugin-core-0.1.15-alpha.0.tgz#e42f202dd57bb4d1627bfed514da8d6aa69244d5"
integrity sha512-iRmip/fa+V/IWxr2H3yHcg4YJmoRUOgqUv0Qvol7dcDK21pF9NasFJVJrMRXoGqhv3S6CI/AHRIhNx1idQ9lSw==
"@spryrocks/logger-plugin-core@^0.1.16-alpha.0":
version "0.1.16-alpha.0"
resolved "https://registry.yarnpkg.com/@spryrocks/logger-plugin-core/-/logger-plugin-core-0.1.16-alpha.0.tgz#1cfe699b0bd5f7c5759bec463ae84c1b567439af"
integrity sha512-/lo2TE0W6o5F7PEgFGB3Z9DPZc6Pr7zCzq001NG4ExLzvbGmOj55M1X5rMq4RfupSQww4G+6LzoVHAfNVXlDpg==
dependencies:
"@spryrocks/logger-core" "^0.1.15-alpha.0"
"@spryrocks/logger-core" "^0.1.16-alpha.0"

"@spryrocks/logger-plugin-observer@^0.1.15-alpha.0":
version "0.1.15-alpha.0"
resolved "https://registry.yarnpkg.com/@spryrocks/logger-plugin-observer/-/logger-plugin-observer-0.1.15-alpha.0.tgz#06ffa53a7f2b2660cae018970abdd87f8dcd395c"
integrity sha512-H5qaNFbSWHL8Lpkf57wGisYlpQ+Wj548vG/Evb47xK9xASVlqctc5PLmCQu1iCoonmzsxMPUv80CX/KcrMciKw==
"@spryrocks/logger-plugin-observer@^0.1.16-alpha.0":
version "0.1.16-alpha.0"
resolved "https://registry.yarnpkg.com/@spryrocks/logger-plugin-observer/-/logger-plugin-observer-0.1.16-alpha.0.tgz#0f0d6f41c8937ddd961f381cd63d74f06356d40a"
integrity sha512-bms3kQwT4RcnMQVS8q8eYeYh0owfPZJlQwL6kWvZUGJ665PPg3LDuF9k5qUTx+c3vTNbhQaTXp7koyCe6sqh8Q==
dependencies:
"@spryrocks/logger-observer" "^0.1.15-alpha.0"
"@spryrocks/logger-plugin-core" "^0.1.15-alpha.0"
"@spryrocks/logger-observer" "^0.1.16-alpha.0"
"@spryrocks/logger-plugin-core" "^0.1.16-alpha.0"

"@spryrocks/logger-plugin@^0.1.15-alpha.1":
version "0.1.15-alpha.1"
resolved "https://registry.yarnpkg.com/@spryrocks/logger-plugin/-/logger-plugin-0.1.15-alpha.1.tgz#dd03b5b85642e24b6f85ed55e0b6b984ab384a39"
integrity sha512-hUzBeJel8zLmN4q7wldq7Wlj804ljpA98juop53EhyYn99c756CAIfdim7nSyXMBlGGltb7wf8p+S413QYkSQg==
"@spryrocks/logger-plugin@^0.1.16-alpha.1":
version "0.1.16-alpha.1"
resolved "https://registry.yarnpkg.com/@spryrocks/logger-plugin/-/logger-plugin-0.1.16-alpha.1.tgz#a9305486b5c76b5bf5cac68d3262bf756f1ba2a4"
integrity sha512-UUVSR52qbr+DzacmFum4gowNGn1W0oRwsFU2dPB2KVrBJmxn4rlng18peLng1kKGGGU1pgSJ0UnVSHfLIFVONw==
dependencies:
"@spryrocks/logger" "^0.1.15-alpha.1"
"@spryrocks/logger-plugin-observer" "^0.1.15-alpha.0"
"@spryrocks/logger" "^0.1.16-alpha.1"
"@spryrocks/logger-plugin-observer" "^0.1.16-alpha.0"

"@spryrocks/logger@^0.1.15-alpha.1":
version "0.1.15-alpha.1"
resolved "https://registry.yarnpkg.com/@spryrocks/logger/-/logger-0.1.15-alpha.1.tgz#66e80ee4283fcf96aca7285cb23ac26881bf739d"
integrity sha512-2iWn8cX3P7veezkkaro/IDUKYf/q3KRp/nBdnkpcR8y+VXxLsNRhptq2BY1LVXJhpoXbEE1kRbTy/5dJ0Uq7jA==
"@spryrocks/logger@^0.1.16-alpha.1":
version "0.1.16-alpha.1"
resolved "https://registry.yarnpkg.com/@spryrocks/logger/-/logger-0.1.16-alpha.1.tgz#b644c08f8baca88248243156d8db18e564c9fcde"
integrity sha512-+Maah+rYnWnmwsvm+PKNL10MtQ2mx+Mj3wFjc8zTA8TK2KtLOnflGST2RjUn+3LCL5vAnESkT24Q5VowZZvNdQ==
dependencies:
"@spryrocks/logger-observer" "^0.1.15-alpha.0"
"@spryrocks/logger-observer" "^0.1.16-alpha.0"

"@spryrocks/prettier-config@^0.3.0-alpha.0":
version "0.3.0-alpha.0"
Expand Down

0 comments on commit ea6761c

Please sign in to comment.