Forgot to generate id for log events
This commit is contained in:
parent
cc092fae03
commit
3736fac4c5
|
@ -21,6 +21,18 @@ export async function uuid(): Promise<string> {
|
||||||
].join("-");
|
].join("-");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates a random UUID v4
|
||||||
|
* NOT CRYPTOGRAPHICALLY SAFE!
|
||||||
|
*/
|
||||||
|
export function unsafeUUID(): string {
|
||||||
|
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
|
||||||
|
var r = (Math.random() * 16) | 0,
|
||||||
|
v = c == "x" ? r : (r & 0x3) | 0x8;
|
||||||
|
return v.toString(16);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/** Caracters, by category */
|
/** Caracters, by category */
|
||||||
export const chars = {
|
export const chars = {
|
||||||
numbers: "0123456789",
|
numbers: "0123456789",
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { Logger, LogEvent } from "@padloc/core/src/logging";
|
import { Logger, LogEvent } from "@padloc/core/src/logging";
|
||||||
|
import { unsafeUUID } from "@padloc/core/src/util";
|
||||||
import { PostgresStorage } from "../storage/postgres";
|
import { PostgresStorage } from "../storage/postgres";
|
||||||
|
|
||||||
export class PostgresLogger implements Logger {
|
export class PostgresLogger implements Logger {
|
||||||
|
@ -6,6 +7,7 @@ export class PostgresLogger implements Logger {
|
||||||
|
|
||||||
log(type: string, data?: any) {
|
log(type: string, data?: any) {
|
||||||
const event = new LogEvent(type, data);
|
const event = new LogEvent(type, data);
|
||||||
|
event.id = unsafeUUID();
|
||||||
(async () => {
|
(async () => {
|
||||||
try {
|
try {
|
||||||
this._storage.save(event);
|
this._storage.save(event);
|
||||||
|
|
Loading…
Reference in New Issue