Merge pull request #30 from tauri-apps/sync-prs/log

fix(store): fix typings
pull/46/head
Jonas Kruckenberg 3 years ago committed by GitHub
commit 3c5a7013fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -6,170 +6,174 @@ async function a(i){return c$1("tauri",i)}
var W={};e(W,{TauriEvent:()=>c,emit:()=>D,listen:()=>E,once:()=>_});async function s(n,t){return a({__tauriModule:"Event",message:{cmd:"unlisten",event:n,eventId:t}})}async function m(n,t,i){await a({__tauriModule:"Event",message:{cmd:"emit",event:n,windowLabel:t,payload:i}});}async function o(n,t,i){return a({__tauriModule:"Event",message:{cmd:"listen",event:n,windowLabel:t,handler:s$1(i)}}).then(r=>async()=>s(n,r))}async function u(n,t,i){return o(n,t,r=>{i(r),s(n,r.id).catch(()=>{});})}var c=(e=>(e.WINDOW_RESIZED="tauri://resize",e.WINDOW_MOVED="tauri://move",e.WINDOW_CLOSE_REQUESTED="tauri://close-requested",e.WINDOW_CREATED="tauri://window-created",e.WINDOW_DESTROYED="tauri://destroyed",e.WINDOW_FOCUS="tauri://focus",e.WINDOW_BLUR="tauri://blur",e.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",e.WINDOW_THEME_CHANGED="tauri://theme-changed",e.WINDOW_FILE_DROP="tauri://file-drop",e.WINDOW_FILE_DROP_HOVER="tauri://file-drop-hover",e.WINDOW_FILE_DROP_CANCELLED="tauri://file-drop-cancelled",e.MENU="tauri://menu",e.CHECK_UPDATE="tauri://update",e.UPDATE_AVAILABLE="tauri://update-available",e.INSTALL_UPDATE="tauri://update-install",e.STATUS_UPDATE="tauri://update-status",e.DOWNLOAD_PROGRESS="tauri://update-download-progress",e))(c||{});async function E(n,t){return o(n,null,t)}async function _(n,t){return u(n,null,t)}async function D(n,t){return m(n,void 0,t)} var W={};e(W,{TauriEvent:()=>c,emit:()=>D,listen:()=>E,once:()=>_});async function s(n,t){return a({__tauriModule:"Event",message:{cmd:"unlisten",event:n,eventId:t}})}async function m(n,t,i){await a({__tauriModule:"Event",message:{cmd:"emit",event:n,windowLabel:t,payload:i}});}async function o(n,t,i){return a({__tauriModule:"Event",message:{cmd:"listen",event:n,windowLabel:t,handler:s$1(i)}}).then(r=>async()=>s(n,r))}async function u(n,t,i){return o(n,t,r=>{i(r),s(n,r.id).catch(()=>{});})}var c=(e=>(e.WINDOW_RESIZED="tauri://resize",e.WINDOW_MOVED="tauri://move",e.WINDOW_CLOSE_REQUESTED="tauri://close-requested",e.WINDOW_CREATED="tauri://window-created",e.WINDOW_DESTROYED="tauri://destroyed",e.WINDOW_FOCUS="tauri://focus",e.WINDOW_BLUR="tauri://blur",e.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",e.WINDOW_THEME_CHANGED="tauri://theme-changed",e.WINDOW_FILE_DROP="tauri://file-drop",e.WINDOW_FILE_DROP_HOVER="tauri://file-drop-hover",e.WINDOW_FILE_DROP_CANCELLED="tauri://file-drop-cancelled",e.MENU="tauri://menu",e.CHECK_UPDATE="tauri://update",e.UPDATE_AVAILABLE="tauri://update-available",e.INSTALL_UPDATE="tauri://update-install",e.STATUS_UPDATE="tauri://update-status",e.DOWNLOAD_PROGRESS="tauri://update-download-progress",e))(c||{});async function E(n,t){return o(n,null,t)}async function _(n,t){return u(n,null,t)}async function D(n,t){return m(n,void 0,t)}
var LogLevel; var LogLevel;
(function (LogLevel) { (function (LogLevel) {
/** /**
* The "trace" level. * The "trace" level.
* *
* Designates very low priority, often extremely verbose, information. * Designates very low priority, often extremely verbose, information.
*/ */
LogLevel[LogLevel["Trace"] = 1] = "Trace"; LogLevel[LogLevel["Trace"] = 1] = "Trace";
/** /**
* The "debug" level. * The "debug" level.
* *
* Designates lower priority information. * Designates lower priority information.
*/ */
LogLevel[LogLevel["Debug"] = 2] = "Debug"; LogLevel[LogLevel["Debug"] = 2] = "Debug";
/** /**
* The "info" level. * The "info" level.
* *
* Designates useful information. * Designates useful information.
*/ */
LogLevel[LogLevel["Info"] = 3] = "Info"; LogLevel[LogLevel["Info"] = 3] = "Info";
/** /**
* The "warn" level. * The "warn" level.
* *
* Designates hazardous situations. * Designates hazardous situations.
*/ */
LogLevel[LogLevel["Warn"] = 4] = "Warn"; LogLevel[LogLevel["Warn"] = 4] = "Warn";
/** /**
* The "error" level. * The "error" level.
* *
* Designates very serious errors. * Designates very serious errors.
*/ */
LogLevel[LogLevel["Error"] = 5] = "Error"; LogLevel[LogLevel["Error"] = 5] = "Error";
})(LogLevel || (LogLevel = {})); })(LogLevel || (LogLevel = {}));
async function log(level, message, options) { async function log(level, message, options) {
var _a, _b; var _a, _b;
const traces = (_a = new Error().stack) === null || _a === void 0 ? void 0 : _a.split("\n").map((line) => line.split("@")); const traces = (_a = new Error().stack) === null || _a === void 0 ? void 0 : _a.split("\n").map((line) => line.split("@"));
const filtered = traces === null || traces === void 0 ? void 0 : traces.filter(([name, location]) => { const filtered = traces === null || traces === void 0 ? void 0 : traces.filter(([name, location]) => {
return name.length > 0 && location !== "[native code]"; return name.length > 0 && location !== "[native code]";
}); });
const { file, line, ...keyValues } = options !== null && options !== void 0 ? options : {}; const { file, line, ...keyValues } = options !== null && options !== void 0 ? options : {};
await c$1("plugin:log|log", { await c$1("plugin:log|log", {
level, level,
message, message,
location: (_b = filtered === null || filtered === void 0 ? void 0 : filtered[0]) === null || _b === void 0 ? void 0 : _b.filter((v) => v.length > 0).join("@"), location: (_b = filtered === null || filtered === void 0 ? void 0 : filtered[0]) === null || _b === void 0 ? void 0 : _b.filter((v) => v.length > 0).join("@"),
file, file,
line, line,
keyValues, keyValues,
}); });
} }
/** /**
* Logs a message at the error level. * Logs a message at the error level.
* *
* @param message * @param message
* *
* # Examples * # Examples
* *
* ```js * ```js
* import { error } from 'tauri-plugin-log-api'; * import { error } from 'tauri-plugin-log-api';
* *
* const err_info = "No connection"; * const err_info = "No connection";
* const port = 22; * const port = 22;
* *
* error(`Error: ${err_info} on port ${port}`); * error(`Error: ${err_info} on port ${port}`);
* ``` * ```
*/ */
async function error(message, options) { async function error(message, options) {
await log(LogLevel.Error, message, options); await log(LogLevel.Error, message, options);
} }
/** /**
* Logs a message at the warn level. * Logs a message at the warn level.
* *
* @param message * @param message
* *
* # Examples * # Examples
* *
* ```js * ```js
* import { warn } from 'tauri-plugin-log-api'; * import { warn } from 'tauri-plugin-log-api';
* *
* const warn_description = "Invalid Input"; * const warn_description = "Invalid Input";
* *
* warn(`Warning! {warn_description}!`); * warn(`Warning! {warn_description}!`);
* ``` * ```
*/ */
async function warn(message, options) { async function warn(message, options) {
await log(LogLevel.Warn, message, options); await log(LogLevel.Warn, message, options);
} }
/** /**
* Logs a message at the info level. * Logs a message at the info level.
* *
* @param message * @param message
* *
* # Examples * # Examples
* *
* ```js * ```js
* import { info } from 'tauri-plugin-log-api'; * import { info } from 'tauri-plugin-log-api';
* *
* const conn_info = { port: 40, speed: 3.20 }; * const conn_info = { port: 40, speed: 3.20 };
* *
* info(`Connected to port {conn_info.port} at {conn_info.speed} Mb/s`); * info(`Connected to port {conn_info.port} at {conn_info.speed} Mb/s`);
* ``` * ```
*/ */
async function info(message, options) { async function info(message, options) {
await log(LogLevel.Info, message, options); await log(LogLevel.Info, message, options);
} }
/** /**
* Logs a message at the debug level. * Logs a message at the debug level.
* *
* @param message * @param message
* *
* # Examples * # Examples
* *
* ```js * ```js
* import { debug } from 'tauri-plugin-log-api'; * import { debug } from 'tauri-plugin-log-api';
* *
* const pos = { x: 3.234, y: -1.223 }; * const pos = { x: 3.234, y: -1.223 };
* *
* debug(`New position: x: {pos.x}, y: {pos.y}`); * debug(`New position: x: {pos.x}, y: {pos.y}`);
* ``` * ```
*/ */
async function debug(message, options) { async function debug(message, options) {
await log(LogLevel.Debug, message, options); await log(LogLevel.Debug, message, options);
} }
/** /**
* Logs a message at the trace level. * Logs a message at the trace level.
* *
* @param message * @param message
* *
* # Examples * # Examples
* *
* ```js * ```js
* import { trace } from 'tauri-plugin-log-api'; * import { trace } from 'tauri-plugin-log-api';
* *
* let pos = { x: 3.234, y: -1.223 }; * let pos = { x: 3.234, y: -1.223 };
* *
* trace(`Position is: x: {pos.x}, y: {pos.y}`); * trace(`Position is: x: {pos.x}, y: {pos.y}`);
* ``` * ```
*/ */
async function trace(message, options) { async function trace(message, options) {
await log(LogLevel.Trace, message, options); await log(LogLevel.Trace, message, options);
} }
async function attachConsole() { async function attachConsole() {
return await E("log://log", (event) => { return await E("log://log", (event) => {
const payload = event.payload; const payload = event.payload;
switch (payload.level) { // Strip ANSI escape codes
case LogLevel.Trace: const message = payload.message.replace(
console.log(payload.message); // eslint-disable-next-line no-control-regex
break; /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, "");
case LogLevel.Debug: switch (payload.level) {
console.debug(payload.message); case LogLevel.Trace:
break; console.log(message);
case LogLevel.Info: break;
console.info(payload.message); case LogLevel.Debug:
break; console.debug(message);
case LogLevel.Warn: break;
console.warn(payload.message); case LogLevel.Info:
break; console.info(message);
case LogLevel.Error: break;
console.error(payload.message); case LogLevel.Warn:
break; console.warn(message);
default: break;
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions case LogLevel.Error:
throw new Error(`unknown log level ${payload.level}`); console.error(message);
} break;
}); default:
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
throw new Error(`unknown log level ${payload.level}`);
}
});
} }
export { attachConsole, debug, error, info, trace, warn }; export { attachConsole, debug, error, info, trace, warn };

File diff suppressed because one or more lines are too long

@ -1,170 +1,174 @@
import { invoke } from '@tauri-apps/api/tauri'; import { invoke } from '@tauri-apps/api/tauri';
import { listen } from '@tauri-apps/api/event'; import { listen } from '@tauri-apps/api/event';
var LogLevel; var LogLevel;
(function (LogLevel) { (function (LogLevel) {
/** /**
* The "trace" level. * The "trace" level.
* *
* Designates very low priority, often extremely verbose, information. * Designates very low priority, often extremely verbose, information.
*/ */
LogLevel[LogLevel["Trace"] = 1] = "Trace"; LogLevel[LogLevel["Trace"] = 1] = "Trace";
/** /**
* The "debug" level. * The "debug" level.
* *
* Designates lower priority information. * Designates lower priority information.
*/ */
LogLevel[LogLevel["Debug"] = 2] = "Debug"; LogLevel[LogLevel["Debug"] = 2] = "Debug";
/** /**
* The "info" level. * The "info" level.
* *
* Designates useful information. * Designates useful information.
*/ */
LogLevel[LogLevel["Info"] = 3] = "Info"; LogLevel[LogLevel["Info"] = 3] = "Info";
/** /**
* The "warn" level. * The "warn" level.
* *
* Designates hazardous situations. * Designates hazardous situations.
*/ */
LogLevel[LogLevel["Warn"] = 4] = "Warn"; LogLevel[LogLevel["Warn"] = 4] = "Warn";
/** /**
* The "error" level. * The "error" level.
* *
* Designates very serious errors. * Designates very serious errors.
*/ */
LogLevel[LogLevel["Error"] = 5] = "Error"; LogLevel[LogLevel["Error"] = 5] = "Error";
})(LogLevel || (LogLevel = {})); })(LogLevel || (LogLevel = {}));
async function log(level, message, options) { async function log(level, message, options) {
var _a, _b; var _a, _b;
const traces = (_a = new Error().stack) === null || _a === void 0 ? void 0 : _a.split("\n").map((line) => line.split("@")); const traces = (_a = new Error().stack) === null || _a === void 0 ? void 0 : _a.split("\n").map((line) => line.split("@"));
const filtered = traces === null || traces === void 0 ? void 0 : traces.filter(([name, location]) => { const filtered = traces === null || traces === void 0 ? void 0 : traces.filter(([name, location]) => {
return name.length > 0 && location !== "[native code]"; return name.length > 0 && location !== "[native code]";
}); });
const { file, line, ...keyValues } = options !== null && options !== void 0 ? options : {}; const { file, line, ...keyValues } = options !== null && options !== void 0 ? options : {};
await invoke("plugin:log|log", { await invoke("plugin:log|log", {
level, level,
message, message,
location: (_b = filtered === null || filtered === void 0 ? void 0 : filtered[0]) === null || _b === void 0 ? void 0 : _b.filter((v) => v.length > 0).join("@"), location: (_b = filtered === null || filtered === void 0 ? void 0 : filtered[0]) === null || _b === void 0 ? void 0 : _b.filter((v) => v.length > 0).join("@"),
file, file,
line, line,
keyValues, keyValues,
}); });
} }
/** /**
* Logs a message at the error level. * Logs a message at the error level.
* *
* @param message * @param message
* *
* # Examples * # Examples
* *
* ```js * ```js
* import { error } from 'tauri-plugin-log-api'; * import { error } from 'tauri-plugin-log-api';
* *
* const err_info = "No connection"; * const err_info = "No connection";
* const port = 22; * const port = 22;
* *
* error(`Error: ${err_info} on port ${port}`); * error(`Error: ${err_info} on port ${port}`);
* ``` * ```
*/ */
async function error(message, options) { async function error(message, options) {
await log(LogLevel.Error, message, options); await log(LogLevel.Error, message, options);
} }
/** /**
* Logs a message at the warn level. * Logs a message at the warn level.
* *
* @param message * @param message
* *
* # Examples * # Examples
* *
* ```js * ```js
* import { warn } from 'tauri-plugin-log-api'; * import { warn } from 'tauri-plugin-log-api';
* *
* const warn_description = "Invalid Input"; * const warn_description = "Invalid Input";
* *
* warn(`Warning! {warn_description}!`); * warn(`Warning! {warn_description}!`);
* ``` * ```
*/ */
async function warn(message, options) { async function warn(message, options) {
await log(LogLevel.Warn, message, options); await log(LogLevel.Warn, message, options);
} }
/** /**
* Logs a message at the info level. * Logs a message at the info level.
* *
* @param message * @param message
* *
* # Examples * # Examples
* *
* ```js * ```js
* import { info } from 'tauri-plugin-log-api'; * import { info } from 'tauri-plugin-log-api';
* *
* const conn_info = { port: 40, speed: 3.20 }; * const conn_info = { port: 40, speed: 3.20 };
* *
* info(`Connected to port {conn_info.port} at {conn_info.speed} Mb/s`); * info(`Connected to port {conn_info.port} at {conn_info.speed} Mb/s`);
* ``` * ```
*/ */
async function info(message, options) { async function info(message, options) {
await log(LogLevel.Info, message, options); await log(LogLevel.Info, message, options);
} }
/** /**
* Logs a message at the debug level. * Logs a message at the debug level.
* *
* @param message * @param message
* *
* # Examples * # Examples
* *
* ```js * ```js
* import { debug } from 'tauri-plugin-log-api'; * import { debug } from 'tauri-plugin-log-api';
* *
* const pos = { x: 3.234, y: -1.223 }; * const pos = { x: 3.234, y: -1.223 };
* *
* debug(`New position: x: {pos.x}, y: {pos.y}`); * debug(`New position: x: {pos.x}, y: {pos.y}`);
* ``` * ```
*/ */
async function debug(message, options) { async function debug(message, options) {
await log(LogLevel.Debug, message, options); await log(LogLevel.Debug, message, options);
} }
/** /**
* Logs a message at the trace level. * Logs a message at the trace level.
* *
* @param message * @param message
* *
* # Examples * # Examples
* *
* ```js * ```js
* import { trace } from 'tauri-plugin-log-api'; * import { trace } from 'tauri-plugin-log-api';
* *
* let pos = { x: 3.234, y: -1.223 }; * let pos = { x: 3.234, y: -1.223 };
* *
* trace(`Position is: x: {pos.x}, y: {pos.y}`); * trace(`Position is: x: {pos.x}, y: {pos.y}`);
* ``` * ```
*/ */
async function trace(message, options) { async function trace(message, options) {
await log(LogLevel.Trace, message, options); await log(LogLevel.Trace, message, options);
} }
async function attachConsole() { async function attachConsole() {
return await listen("log://log", (event) => { return await listen("log://log", (event) => {
const payload = event.payload; const payload = event.payload;
switch (payload.level) { // Strip ANSI escape codes
case LogLevel.Trace: const message = payload.message.replace(
console.log(payload.message); // eslint-disable-next-line no-control-regex
break; /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, "");
case LogLevel.Debug: switch (payload.level) {
console.debug(payload.message); case LogLevel.Trace:
break; console.log(message);
case LogLevel.Info: break;
console.info(payload.message); case LogLevel.Debug:
break; console.debug(message);
case LogLevel.Warn: break;
console.warn(payload.message); case LogLevel.Info:
break; console.info(message);
case LogLevel.Error: break;
console.error(payload.message); case LogLevel.Warn:
break; console.warn(message);
default: break;
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions case LogLevel.Error:
throw new Error(`unknown log level ${payload.level}`); console.error(message);
} break;
}); default:
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
throw new Error(`unknown log level ${payload.level}`);
}
});
} }
export { attachConsole, debug, error, info, trace, warn }; export { attachConsole, debug, error, info, trace, warn };

@ -1 +1 @@
{"version":3,"file":"index.mjs","sources":["../index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAQA,IAAK,QA+BJ,CAAA;AA/BD,CAAA,UAAK,QAAQ,EAAA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AACzC,QAAA,MAAM,OAAO,GAAG,KAAK,CAAC,OAAwB,CAAC;;AAG/C,QAAA,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO;;QAErC,6EAA6E,EAC7E,EAAE,CACH,CAAC;QAEF,QAAQ,OAAO,CAAC,KAAK;YACnB,KAAK,QAAQ,CAAC,KAAK;AACjB,gBAAA,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;gBACrB,MAAM;YACR,KAAK,QAAQ,CAAC,KAAK;AACjB,gBAAA,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;gBACvB,MAAM;YACR,KAAK,QAAQ,CAAC,IAAI;AAChB,gBAAA,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBACtB,MAAM;YACR,KAAK,QAAQ,CAAC,IAAI;AAChB,gBAAA,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBACtB,MAAM;YACR,KAAK,QAAQ,CAAC,KAAK;AACjB,gBAAA,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;gBACvB,MAAM;AACR,YAAA;;gBAEE,MAAM,IAAI,KAAK,CAAC,CAAA,kBAAA,EAAqB,OAAO,CAAC,KAAK,CAAE,CAAA,CAAC,CAAC;AACzD,SAAA;AACH,KAAC,CAAC,CAAC;AACL;;;;"}

@ -182,21 +182,28 @@ export async function attachConsole(): Promise<UnlistenFn> {
return await listen("log://log", (event) => { return await listen("log://log", (event) => {
const payload = event.payload as RecordPayload; const payload = event.payload as RecordPayload;
// Strip ANSI escape codes
const message = payload.message.replace(
// eslint-disable-next-line no-control-regex
/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,
""
);
switch (payload.level) { switch (payload.level) {
case LogLevel.Trace: case LogLevel.Trace:
console.log(payload.message); console.log(message);
break; break;
case LogLevel.Debug: case LogLevel.Debug:
console.debug(payload.message); console.debug(message);
break; break;
case LogLevel.Info: case LogLevel.Info:
console.info(payload.message); console.info(message);
break; break;
case LogLevel.Warn: case LogLevel.Warn:
console.warn(payload.message); console.warn(message);
break; break;
case LogLevel.Error: case LogLevel.Error:
console.error(payload.message); console.error(message);
break; break;
default: default:
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions // eslint-disable-next-line @typescript-eslint/restrict-template-expressions

Loading…
Cancel
Save