mirror of
https://github.com/darksaid98/oxmysql.git
synced 2026-12-02 14:38:50 +00:00
refactor(logger): dynamically load logger service
This commit is contained in:
1 parent
f005a2f200
commit
9920ae7ffe
4 files changed
+31
-27
No files matched your search
+13
-1
@@ -2,11 +2,14 @@ import { mysql_debug, mysql_log_size, mysql_slow_query_warning, mysql_ui } from
|
||||
import type { CFXCallback, CFXParameters } from '../types';
|
||||
import { dbVersion } from '../database';
|
||||
|
||||
const loggerService = GetConvar('mysql_logger_service', '');
|
||||
export const logger = new Function(LoadResourceFile('oxmysql', `logger/${loggerService}.js`))() || (() => {});
|
||||
|
||||
export function logError(
|
||||
invokingResource: string,
|
||||
cb: CFXCallback | undefined,
|
||||
isPromise: boolean | undefined,
|
||||
err: Error | string = '',
|
||||
err: any | string = '', // i cbf typing the error right now
|
||||
query?: string,
|
||||
parameters?: CFXParameters,
|
||||
includeParameters?: boolean
|
||||
@@ -25,6 +28,15 @@ export function logError(
|
||||
resource: invokingResource,
|
||||
});
|
||||
|
||||
if (typeof err === 'object' && err.message) delete err.sqlMessage;
|
||||
|
||||
logger({
|
||||
level: 'error',
|
||||
resource: invokingResource,
|
||||
message: message,
|
||||
metadata: err,
|
||||
});
|
||||
|
||||
if (cb && isPromise) return cb(null, output);
|
||||
|
||||
console.error(output);
|
||||
|
||||
Reference in new issue
Block a user