Merged in feature/wrap-logging (pull request #2511)

Feature/wrap logging

* feat: change all logging to go through our own logger function so that we can control log levels

* move packages/trpc to using our own logger

* merge


Approved-by: Linus Flood
This commit is contained in:
Joakim Jäderberg
2025-07-03 12:37:04 +00:00
parent 7e32ed294d
commit daf765f3d5
110 changed files with 681 additions and 441 deletions

View File

@@ -2,12 +2,15 @@ import "server-only"
import crypto from "crypto"
import { createLogger } from "@scandic-hotels/common/logger/createLogger"
import { env } from "../../env/server"
const algorithm = "DES-ECB"
const encryptionKey = env.BOOKING_ENCRYPTION_KEY
const bufferKey = Buffer.from(encryptionKey, "utf8")
const encryptionLogger = createLogger("encryption")
export function encrypt(originalString: string) {
try {
const cipher = crypto.createCipheriv(algorithm, bufferKey, null)
@@ -25,7 +28,7 @@ export function encrypt(originalString: string) {
const result = Buffer.concat(buffers).toString("base64")
return result
} catch (e) {
console.log(e)
encryptionLogger.error("encryption error", e)
return ""
}
}
@@ -46,7 +49,7 @@ export function decrypt(encryptedString: string) {
.replace(/(\x00)*/g, "")
return result
} catch (e) {
console.log(e)
encryptionLogger.error("decryption error", e)
return ""
}
}