@514labs/moose-lib 0.6.260-ci-5-g3b5261dd → 0.6.260-ci-2-g1b93253f

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -39,6 +39,36 @@ function isTruthy(value) {
39
39
  return false;
40
40
  }
41
41
  }
42
+ function parseLogLevel(value) {
43
+ if (!value) return "Info" /* Info */;
44
+ const normalized = value.trim();
45
+ switch (normalized) {
46
+ case "Debug":
47
+ case "debug":
48
+ case "DEBUG":
49
+ return "Debug" /* Debug */;
50
+ case "Info":
51
+ case "info":
52
+ case "INFO":
53
+ return "Info" /* Info */;
54
+ case "Warn":
55
+ case "warn":
56
+ case "WARN":
57
+ return "Warn" /* Warn */;
58
+ case "Error":
59
+ case "error":
60
+ case "ERROR":
61
+ return "Error" /* Error */;
62
+ default:
63
+ return "Info" /* Info */;
64
+ }
65
+ }
66
+ function getLogLevel() {
67
+ if (cachedLogLevel === null) {
68
+ cachedLogLevel = parseLogLevel(process.env.MOOSE_LOGGER__LEVEL);
69
+ }
70
+ return cachedLogLevel;
71
+ }
42
72
  function createProducerConfig(maxMessageBytes) {
43
73
  return {
44
74
  kafkaJS: {
@@ -55,7 +85,7 @@ function createProducerConfig(maxMessageBytes) {
55
85
  ...maxMessageBytes && { "message.max.bytes": maxMessageBytes }
56
86
  };
57
87
  }
58
- var import_http, import_client, import_kafka_javascript, Kafka, compilerLog, getClickhouseClient, cliLog, MAX_RETRIES, MAX_RETRY_TIME_MS, RETRY_INITIAL_TIME_MS, MAX_RETRIES_PRODUCER, ACKs, parseBrokerString, logError, buildSaslConfig, getKafkaClient;
88
+ var import_http, import_client, import_kafka_javascript, Kafka, cachedLogLevel, compilerLog, getClickhouseClient, cliLog, MAX_RETRIES, MAX_RETRY_TIME_MS, RETRY_INITIAL_TIME_MS, MAX_RETRIES_PRODUCER, ACKs, parseBrokerString, logError, buildSaslConfig, getKafkaClient;
59
89
  var init_commons = __esm({
60
90
  "src/commons.ts"() {
61
91
  "use strict";
@@ -63,8 +93,19 @@ var init_commons = __esm({
63
93
  import_client = require("@clickhouse/client");
64
94
  import_kafka_javascript = require("@confluentinc/kafka-javascript");
65
95
  ({ Kafka } = import_kafka_javascript.KafkaJS);
66
- compilerLog = (message) => {
67
- if (!isTruthy(process.env.MOOSE_DISABLE_COMPILER_LOGS)) {
96
+ cachedLogLevel = null;
97
+ compilerLog = (message, level = "Debug" /* Debug */) => {
98
+ if (isTruthy(process.env.MOOSE_DISABLE_COMPILER_LOGS)) {
99
+ return;
100
+ }
101
+ const currentLevel = getLogLevel();
102
+ const levelPriority = {
103
+ ["Debug" /* Debug */]: 0,
104
+ ["Info" /* Info */]: 1,
105
+ ["Warn" /* Warn */]: 2,
106
+ ["Error" /* Error */]: 3
107
+ };
108
+ if (levelPriority[level] >= levelPriority[currentLevel]) {
68
109
  console.log(message);
69
110
  }
70
111
  };