Log errors in secu type
MODIFY
src/utils/Logging.ts
src/utils/Logging.ts
@@ -59,12 +59,6 @@ obs.observe({ entryTypes: ['measure'] });
export default class Logging {
private static traceOCPPCalls: { [key: string]: number } = {};
- // Log Debug
- public static logDebug(log: Log): void {
- log.level = LogLevel.DEBUG;
- Logging._log(log);
- }
-
// Debug DB
public static traceStart(module: string, method: string): string {
let uniqueID = '0';
@@ -106,6 +100,18 @@ export default class Logging {
}
}
+ // Log Debug
+ public static logDebug(log: Log): void {
+ log.level = LogLevel.DEBUG;
+ Logging._log(log);
+ }
+
+ // Log Security Debug
+ public static logSecurityDebug(log: Log): void {
+ log.type = LogType.SECURITY;
+ Logging.logDebug(log);
+ }
+
// Log Info
public static logInfo(log: Log): void {
log.level = LogLevel.INFO;
@@ -164,7 +170,7 @@ export default class Logging {
}
req['timestamp'] = new Date();
// Log
- Logging.logDebug({
+ Logging.logSecurityDebug({
tenantID: tenantID,
action: ServerAction.HTTP_REQUEST,
user: userToken,
@@ -203,7 +209,7 @@ export default class Logging {
if (res.getHeader('content-length')) {
contentLengthKB = res.getHeader('content-length') as number / 1000;
}
- Logging.logDebug({
+ Logging.logSecurityDebug({
tenantID: tenantID,
user: req.user,
action: ServerAction.HTTP_RESPONSE,
@@ -227,7 +233,7 @@ export default class Logging {
public static logAxiosRequest(tenantID: string, request: AxiosRequestConfig): void {
request['timestamp'] = new Date();
- Logging.logDebug({
+ Logging.logSecurityDebug({
tenantID: tenantID,
action: ServerAction.HTTP_REQUEST,
message: `Axios HTTP Request >> ${request.method.toLocaleUpperCase()} '${request.url}'`,
@@ -247,7 +253,7 @@ export default class Logging {
if (response.config.headers['Content-Length']) {
contentLengthKB = response.config.headers['Content-Length'] / 1000;
}
- Logging.logDebug({
+ Logging.logSecurityDebug({
tenantID: tenantID,
action: ServerAction.HTTP_RESPONSE,
message: `Axios HTTP Response - ${(durationSecs > 0) ? durationSecs : '?'}s - ${(contentLengthKB > 0) ? contentLengthKB : '?'}kB << ${response.config.method.toLocaleUpperCase()}/${response.status} '${response.config.url}'`,
@@ -263,7 +269,7 @@ export default class Logging {
public static logAxiosError(tenantID: string, error: AxiosError): void {
// Error handling is done outside to get the proper module information
- Logging.logError({
+ Logging.logSecurityError({
tenantID: tenantID,
action: ServerAction.HTTP_ERROR,
message: `Axios HTTP Error >> ${error.config.method.toLocaleUpperCase()}/${error.response.status} '${error.config.url}' - ${error.message}`,
@@ -385,6 +391,7 @@ export default class Logging {
// Log
Logging.logError({
tenantID: tenantID,
+ type: LogType.SECURITY,
user: exception.user,
source: exception.source,
module: exception.module,
@@ -410,6 +417,7 @@ export default class Logging {
// Log
Logging.logError({
tenantID: tenantID,
+ type: LogType.SECURITY,
source: exception.params.source,
user: exception.params.user,
actionOnUser: exception.params.actionOnUser,
@@ -436,6 +444,7 @@ export default class Logging {
// Log
Logging.logError({
tenantID: tenantID,
+ type: LogType.SECURITY,
source: exception.params.source,
module: exception.params.module,
method: exception.params.method,
@@ -452,6 +461,7 @@ export default class Logging {
// Log
Logging.logSecurityError({
tenantID: tenantID,
+ type: LogType.SECURITY,
user: exception.params.user,
actionOnUser: exception.params.actionOnUser,
module: exception.params.module,

Log errors in secu type