Commit a3bbd310 authored by Muhammad Umair Khan's avatar Muhammad Umair Khan
Browse files

update log level & integration with meepctl

parent 500bd88a
Loading
Loading
Loading
Loading
+13 −9
Original line number Diff line number Diff line
@@ -23,9 +23,9 @@ repo:
    # permissions
    permissions:
      # user id
      uid: 1000
      uid: 1001
      # group id
      gid: 1000
      gid: 1001

    # user supplied resources
    user:
@@ -38,7 +38,7 @@ repo:
    # platform ingress configuration
    ingress:
      # host name
      host: 192.168.20.167
      host: try-mec.etsi.org
      # enable https only (redirect http requests to https port)
      https-only: true
      # bind to host ports (true) or node ports (false)
@@ -48,7 +48,7 @@ repo:
      # https config
      https-port: 443
      # certificate authority (none|self-signed|lets-encrypt) default: none
      ca: self-signed
      ca: lets-encrypt
      # lets-encrypt production server (true) or staging server (false)
      le-server-prod: true

@@ -79,7 +79,7 @@ repo:
        # access token url
        token-url: https://github.com/login/oauth/access_token
        # OAuth redirect URI
        redirect-uri: https://192.168.20.167/platform-ctrl/v1/authorize
        redirect-uri: https://try-mec.etsi.org/platform-ctrl/v1/authorize
        # OAuth k8s secret (data: client-id, secret)
        secret: meep-oauth-github
      # GitLab OAuth provider config
@@ -102,7 +102,7 @@ repo:
      # Influx configuration
      influx:
        # enable influx data backups
        enabled: true
        enabled: false
        # object store url
        url: https://metrics.try-mec.etsi.org/
        # object store configuration secret
@@ -152,11 +152,11 @@ repo:
            # 1h downsampled data retention
            resolution-1h: 10y
      # Thanos long-term storage archive
      #thanos-archive:
      thanos-archive:
        # enable Thanos archive
        # enabled: true
        enabled: true
        # archive object store configuration secret
        #secret: meep-thanos-archive-objstore-config
        secret: meep-thanos-archive-objstore-config

    # Garbage Collection configuration
    gc:
@@ -500,6 +500,10 @@ repo:
          meep-gis-engine-api: js-packages/meep-gis-engine-client
          meep-auth-svc-client: js-packages/meep-auth-svc-client
          meep-metrics-engine-api: js-packages/meep-metrics-engine-client
        # environment variables to inject during build
        # LOG_LEVEL allowed values: TRACE | DEBUG | INFO | WARN | ERROR
        env:
          LOG_LEVEL: DEBUG

  #------------------------------
  #  Sandbox Subsystem
+28 −12
Original line number Diff line number Diff line
import log from 'loglevel';
import prefix from 'loglevel-plugin-prefix';
import { LOG_TYPES } from './log-types';

// Configure the prefix plugin
prefix.reg(log);
const COLORS = {
  [LOG_TYPES.TRACE]: 'magenta',
  [LOG_TYPES.DEBUG]: 'cyan',
  [LOG_TYPES.INFO]: 'blue',
  [LOG_TYPES.WARN]: 'goldenrod',
  [LOG_TYPES.ERROR]: 'red'
};

prefix.apply(log, {
  format(level, name, timestamp) {
    return `[${timestamp}] ${level.toUpperCase()}${name ? ` (${name})` : ''}:`;
  }
});
const originalFactory = log.methodFactory;
log.methodFactory = function (methodName, logLevel, loggerName) {
  const rawMethod = originalFactory(methodName, logLevel, loggerName);
  return function (...args) {
    const level = methodName.toUpperCase();
    const color = COLORS[level] || 'black';
    const timestamp = new Date().toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, '$1');
    const prefix = `[${timestamp}] ${level}${loggerName ? ` (${loggerName})` : ''}:`;

    // Use %c to format the prefix with CSS matching meepctl colors
    rawMethod(`%c${prefix}`, `color: ${color}; font-weight: bold;`, ...args);
  };
};

// Set default level to debug for better visibility
// Set default level based on environment variable
/* eslint-disable no-undef */
if (process.env.NODE_ENV === 'production') {
  log.setLevel('info');
const envLevel = process.env.LOG_LEVEL;
if (envLevel) {
  log.setLevel(envLevel);
} else if (process.env.NODE_ENV === 'production') {
  log.setLevel(LOG_TYPES.INFO);
} else {
  log.setLevel('debug');
  log.setLevel(LOG_TYPES.DEBUG);
}
/* eslint-enable no-undef */

+2 −1
Original line number Diff line number Diff line
@@ -104,7 +104,8 @@ module.exports = env => {
      extractPlugin,
      htmlPlugin,
      new webpack.DefinePlugin({
        __VERSION__: JSON.stringify('v0.0.0')
        __VERSION__: JSON.stringify('v0.0.0'),
        'process.env.LOG_LEVEL': JSON.stringify(process.env.LOG_LEVEL || '')
      })
    ],
    devServer: {
+1207 −1207

File changed.

Contains only whitespace changes.