From a19a17be42696958ac1afbdbbdfa8acdd6d0a77c Mon Sep 17 00:00:00 2001 From: Tanmoy Sen Gupta Date: Fri, 17 Jun 2022 19:14:56 +0530 Subject: [PATCH] Revert "Added Monitor Config Parser - #39" This reverts commit 4c68abe5ab103c14c8ace5b8424d36057383c17a. --- libraries/js/logsmith/logsmith.js | 3 - .../js/logsmith/monitor/monitorConfigs.js | 61 ++----------------- 2 files changed, 4 insertions(+), 60 deletions(-) diff --git a/libraries/js/logsmith/logsmith.js b/libraries/js/logsmith/logsmith.js index 8689a4e..f011627 100644 --- a/libraries/js/logsmith/logsmith.js +++ b/libraries/js/logsmith/logsmith.js @@ -2,7 +2,6 @@ import * as path from 'path'; import compile from 'string-template/compile.js'; import { loggerRunner } from './lib/drivers.js'; import { readConfigFile } from './lib/fetchConfigs.js'; -import { getMonitorConfigs } from './monitor/monitorConfigs.js'; import { LogFormats, LogLevels, DefaultLogStatementPattern } from './lib/specs.js'; @@ -25,13 +24,11 @@ export default class Logsmith { this.logFormat = Object.values(LogFormats).includes(configs.logFormat) ? configs.logFormat : LogFormats.JSON this.logStatementPattern = configs.logStatementPattern || DefaultLogStatementPattern this.compiledLogPattern = compile(this.logStatementPattern) - this.monitorConfigs = getMonitorConfigs(configs) } else { return Error("File format error. Should be json or env.") } } - INFO(log) { loggerRunner( LogLevels.INFO, diff --git a/libraries/js/logsmith/monitor/monitorConfigs.js b/libraries/js/logsmith/monitor/monitorConfigs.js index 671fd40..868b27e 100644 --- a/libraries/js/logsmith/monitor/monitorConfigs.js +++ b/libraries/js/logsmith/monitor/monitorConfigs.js @@ -1,57 +1,4 @@ -import compile from "string-template/compile.js" - -const URITemplate = compile("{0}:{1}"); -const DefaultPublisherTemplate = { - Origin: compile("app.{0}.com"), - Description: compile("Logs Published by {0}") -} -const DefaultContextTemplate = { - Origin: compile("app.{0}.com/{1}"), - Description: compile("Log Published by {0} to context {1}"), - Kind: { - logs: [] - } -} - -function formatPublisherConfig(monitorConfig) { - const publisherConfig = {} - publisherConfig.publisher = monitorConfig.publisher || process.env.PUBLISHER - publisherConfig.origin = monitorConfig.origin || DefaultPublisherTemplate.Origin(publisherConfig.publisher) - publisherConfig.description = monitorConfig.description || DefaultPublisherTemplate.Description(publisherConfig.publisher) - return publisherConfig -} - -function formatCotextConfig(publisher, monitorConfig) { - const contextConfig = {} - contextConfig.context = monitorConfig.context || process.env.CONTEXT - contextConfig.origin = monitorConfig.origin || DefaultContextTemplate.Origin(publisher, contextConfig.context) - contextConfig.description = monitorConfig.description || DefaultPublisherTemplate.Description(publisher, contextConfig.context) - contextConfig.kind = monitorConfig.kind || DefaultContextTemplate.Kind - return contextConfig -} - -export function getMonitorConfigs(config) { - const monitorConfigs = {} - monitorConfigs.monitorPort = config.MONITOR.port || process.env.MONITOR_PORT - monitorConfigs.monitorURI = config.MONITOR.server || process.env.MONITOR_URI - monitorConfigs.monitorListener = URITemplate(monitorConfigs.monitorURI, monitorConfigs.monitorPort) || process.env.LISTENER - monitorConfigs.publisher = formatPublisherConfig(config.MONITOR.publisher) - monitorConfigs.context = formatCotextConfig(monitorConfigs.publisher.publisher, config.MONITOR.context) - return monitorConfigs -} - -// can be used for test -// console.log( -// getMonitorConfigs({ -// MONITOR: { -// port: "8080", -// server: "localhost", -// publisher: { -// publisher: "test" -// }, -// context: { -// context: "testcon" -// } -// } -// }) -// ) \ No newline at end of file +export function getMonitorConfigs(params) { + var monitorAddresses = [] + +} \ No newline at end of file