befly 3.16.0 → 3.16.2

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.
package/dist/befly.js CHANGED
@@ -504,10 +504,8 @@ import { createWriteStream, existsSync, mkdirSync } from "fs";
504
504
  import { stat } from "fs/promises";
505
505
  import { hostname as osHostname } from "os";
506
506
  import { isAbsolute as nodePathIsAbsolute, join as nodePathJoin, resolve as nodePathResolve } from "path";
507
- function buildSanitizeOptionsForWrite(writeOptions) {
508
- if (!writeOptions)
509
- return sanitizeOptions;
510
- if (writeOptions.truncate !== false)
507
+ function buildSanitizeOptionsForWriteOptions(writeOptions) {
508
+ if (!writeOptions || writeOptions.truncate !== false)
511
509
  return sanitizeOptions;
512
510
  return {
513
511
  maxStringLen: 200000,
@@ -809,8 +807,6 @@ async function flush() {
809
807
  async function shutdown() {
810
808
  if (mockInstance)
811
809
  return;
812
- const currentInstance = instance;
813
- const currentErrorInstance = errorInstance;
814
810
  const currentAppFileSink = appFileSink;
815
811
  const currentErrorFileSink = errorFileSink;
816
812
  const currentAppConsoleSink = appConsoleSink;
@@ -835,12 +831,6 @@ async function shutdown() {
835
831
  if (appConsoleSink === currentAppConsoleSink) {
836
832
  appConsoleSink = null;
837
833
  }
838
- if (instance === currentInstance) {
839
- instance = null;
840
- }
841
- if (errorInstance === currentErrorInstance) {
842
- errorInstance = null;
843
- }
844
834
  }
845
835
  function resolveLogDir() {
846
836
  const rawDir = config.dir || "./logs";
@@ -876,8 +866,6 @@ function configure(cfg) {
876
866
  mb = 100;
877
867
  config.maxSize = mb;
878
868
  }
879
- instance = null;
880
- errorInstance = null;
881
869
  appFileSink = null;
882
870
  errorFileSink = null;
883
871
  appConsoleSink = null;
@@ -893,35 +881,6 @@ function configure(cfg) {
893
881
  function setMockLogger(mock) {
894
882
  mockInstance = mock;
895
883
  }
896
- function getSink(kind) {
897
- if (mockInstance)
898
- return mockInstance;
899
- if (kind === "app") {
900
- if (instance)
901
- return instance;
902
- } else {
903
- if (errorInstance)
904
- return errorInstance;
905
- }
906
- ensureLogDirExists();
907
- const maxSizeMb = typeof config.maxSize === "number" ? config.maxSize : 20;
908
- const maxFileBytes = Math.floor(maxSizeMb * 1024 * 1024);
909
- if (kind === "app") {
910
- if (!appFileSink) {
911
- appFileSink = new LogFileSink({ prefix: "app", maxFileBytes });
912
- }
913
- if (config.console === 1 && !appConsoleSink) {
914
- appConsoleSink = createStreamSink("stdout");
915
- }
916
- instance = createSinkLogger({ fileSink: appFileSink, consoleSink: config.console === 1 ? appConsoleSink : null });
917
- return instance;
918
- }
919
- if (!errorFileSink) {
920
- errorFileSink = new LogFileSink({ prefix: "error", maxFileBytes });
921
- }
922
- errorInstance = createSinkLogger({ fileSink: errorFileSink, consoleSink: null });
923
- return errorInstance;
924
- }
925
884
  function buildBaseFields(level, timeMs) {
926
885
  const base = {
927
886
  level,
@@ -978,46 +937,39 @@ function safeJsonStringify(obj) {
978
937
  }
979
938
  }
980
939
  }
981
- function createSinkLogger(options) {
982
- const fileSink = options.fileSink;
983
- const consoleSink = options.consoleSink;
984
- const write = (level, record) => {
985
- if (level === "debug" && config.debug !== 1)
986
- return;
987
- const time = Date.now();
988
- const base = buildBaseFields(level, time);
989
- const input = isPlainObject(record) ? record : { value: record };
990
- let writeOptions = null;
991
- if (input && typeof input === "object") {
992
- writeOptions = recordWriteOptions.get(input) ?? null;
993
- if (writeOptions) {
994
- recordWriteOptions.delete(input);
995
- }
940
+ function ensureSinksReady(kind) {
941
+ ensureLogDirExists();
942
+ const maxSizeMb = typeof config.maxSize === "number" ? config.maxSize : 20;
943
+ const maxFileBytes = Math.floor(maxSizeMb * 1024 * 1024);
944
+ if (kind === "app") {
945
+ if (!appFileSink) {
946
+ appFileSink = new LogFileSink({ prefix: "app", maxFileBytes });
996
947
  }
997
- const effectiveSanitizeOptions = buildSanitizeOptionsForWrite(writeOptions);
998
- const sanitizedRecord = sanitizeLogObject(input, effectiveSanitizeOptions);
999
- const fileLine = buildLogLineWithBase(base, sanitizedRecord);
1000
- fileSink.enqueue(fileLine);
1001
- if (consoleSink) {
1002
- if (!writeOptions || writeOptions.console !== false) {
1003
- consoleSink.enqueue(fileLine);
1004
- }
948
+ if (config.console === 1 && !appConsoleSink) {
949
+ appConsoleSink = createStreamSink("stdout");
1005
950
  }
1006
- };
1007
- return {
1008
- info(record) {
1009
- write("info", record);
1010
- },
1011
- warn(record) {
1012
- write("warn", record);
1013
- },
1014
- error(record) {
1015
- write("error", record);
1016
- },
1017
- debug(record) {
1018
- write("debug", record);
951
+ return { fileSink: appFileSink, consoleSink: config.console === 1 ? appConsoleSink : null };
952
+ }
953
+ if (!errorFileSink) {
954
+ errorFileSink = new LogFileSink({ prefix: "error", maxFileBytes });
955
+ }
956
+ return { fileSink: errorFileSink, consoleSink: null };
957
+ }
958
+ function writeJsonl(kind, level, record, options) {
959
+ if (level === "debug" && config.debug !== 1)
960
+ return;
961
+ const sinks = ensureSinksReady(kind);
962
+ const time = Date.now();
963
+ const base = buildBaseFields(level, time);
964
+ const effectiveSanitizeOptions = buildSanitizeOptionsForWriteOptions(options);
965
+ const sanitizedRecord = sanitizeLogObject(record, effectiveSanitizeOptions);
966
+ const fileLine = buildLogLineWithBase(base, sanitizedRecord);
967
+ sinks.fileSink.enqueue(fileLine);
968
+ if (sinks.consoleSink) {
969
+ if (!options || options.console !== false) {
970
+ sinks.consoleSink.enqueue(fileLine);
1019
971
  }
1020
- };
972
+ }
1021
973
  }
1022
974
  function metaToObject() {
1023
975
  const meta = getCtx();
@@ -1080,48 +1032,59 @@ function withRequestMetaRecord(record) {
1080
1032
  }
1081
1033
 
1082
1034
  class LoggerFacade {
1083
- maybeSanitizeForMock(record, options) {
1084
- if (!mockInstance)
1085
- return record;
1086
- const effective = buildSanitizeOptionsForWrite(options ? options : null);
1087
- return sanitizeLogObject(record, effective);
1088
- }
1089
- info(input, options) {
1035
+ write(level, input, options) {
1036
+ if (level === "debug" && config.debug !== 1)
1037
+ return;
1090
1038
  const record0 = withRequestMetaRecord(toRecord(input));
1091
- if (!mockInstance && options && isPlainObject(record0)) {
1092
- recordWriteOptions.set(record0, options);
1039
+ if (mockInstance) {
1040
+ const effective = buildSanitizeOptionsForWriteOptions(options);
1041
+ const sanitized = sanitizeLogObject(record0, effective);
1042
+ if (level === "info") {
1043
+ mockInstance.info(sanitized);
1044
+ } else if (level === "warn") {
1045
+ mockInstance.warn(sanitized);
1046
+ } else if (level === "error") {
1047
+ mockInstance.error(sanitized);
1048
+ } else {
1049
+ mockInstance.debug(sanitized);
1050
+ }
1051
+ return;
1052
+ }
1053
+ writeJsonl("app", level, record0, options);
1054
+ if (level === "error") {
1055
+ writeJsonl("error", "error", record0, options);
1093
1056
  }
1094
- const record = this.maybeSanitizeForMock(record0, options);
1095
- getSink("app").info(record);
1057
+ }
1058
+ info(input, options) {
1059
+ this.write("info", input, options);
1096
1060
  }
1097
1061
  warn(input, options) {
1098
- const record0 = withRequestMetaRecord(toRecord(input));
1099
- if (!mockInstance && options && isPlainObject(record0)) {
1100
- recordWriteOptions.set(record0, options);
1101
- }
1102
- const record = this.maybeSanitizeForMock(record0, options);
1103
- getSink("app").warn(record);
1062
+ this.write("warn", input, options);
1104
1063
  }
1105
1064
  error(input, options) {
1106
- const record0 = withRequestMetaRecord(toRecord(input));
1107
- if (!mockInstance && options && isPlainObject(record0)) {
1108
- recordWriteOptions.set(record0, options);
1109
- }
1110
- const record = this.maybeSanitizeForMock(record0, options);
1111
- getSink("app").error(record);
1112
- if (mockInstance)
1113
- return;
1114
- getSink("error").error(record);
1065
+ this.write("error", input, options);
1115
1066
  }
1116
1067
  debug(input, options) {
1117
- if (config.debug !== 1)
1118
- return;
1119
- const record0 = withRequestMetaRecord(toRecord(input));
1120
- if (!mockInstance && options && isPlainObject(record0)) {
1121
- recordWriteOptions.set(record0, options);
1122
- }
1123
- const record = this.maybeSanitizeForMock(record0, options);
1124
- getSink("app").debug(record);
1068
+ this.write("debug", input, options);
1069
+ }
1070
+ printPlainLines(input, options) {
1071
+ const kind = options && options.stream === "stderr" ? "stderr" : "stdout";
1072
+ const stream = kind === "stderr" ? process.stderr : process.stdout;
1073
+ try {
1074
+ if (Array.isArray(input)) {
1075
+ for (const line of input) {
1076
+ stream.write(`${String(line)}
1077
+ `);
1078
+ }
1079
+ return;
1080
+ }
1081
+ const parts = String(input).split(`
1082
+ `);
1083
+ for (let i = 0;i < parts.length; i = i + 1) {
1084
+ stream.write(`${parts[i]}
1085
+ `);
1086
+ }
1087
+ } catch {}
1125
1088
  }
1126
1089
  async flush() {
1127
1090
  await flush();
@@ -1136,7 +1099,7 @@ class LoggerFacade {
1136
1099
  await shutdown();
1137
1100
  }
1138
1101
  }
1139
- var INITIAL_CWD, BUILTIN_SENSITIVE_KEYS, sanitizeOptions, recordWriteOptions, HOSTNAME, instance = null, errorInstance = null, mockInstance = null, appFileSink = null, errorFileSink = null, appConsoleSink = null, config, Logger;
1102
+ var INITIAL_CWD, BUILTIN_SENSITIVE_KEYS, sanitizeOptions, HOSTNAME, mockInstance = null, appFileSink = null, errorFileSink = null, appConsoleSink = null, config, Logger;
1140
1103
  var init_logger = __esm(() => {
1141
1104
  init_loggerUtils();
1142
1105
  init_util();
@@ -1151,7 +1114,6 @@ var init_logger = __esm(() => {
1151
1114
  sanitizeObjectKeys: 500,
1152
1115
  sensitiveKeyMatcher: buildSensitiveKeyMatcher({ builtinPatterns: BUILTIN_SENSITIVE_KEYS, userPatterns: [] })
1153
1116
  };
1154
- recordWriteOptions = new WeakMap;
1155
1117
  HOSTNAME = (() => {
1156
1118
  try {
1157
1119
  return osHostname();
@@ -8600,7 +8562,7 @@ function inferInputByDbType(dbType) {
8600
8562
  if (DECIMAL_DB_TYPES.has(normalized) || FLOAT_DB_TYPES.has(normalized)) {
8601
8563
  return "number";
8602
8564
  }
8603
- if (STRING_DB_TYPES.has(normalized) || normalized === "datetime") {
8565
+ if (STRING_DB_TYPES.has(normalized) || normalized === "datetime" || normalized === "timestamp") {
8604
8566
  return "string";
8605
8567
  }
8606
8568
  if (normalized === "json") {
@@ -8635,7 +8597,7 @@ function parseEnumRuleValues(enumInput) {
8635
8597
  init_util();
8636
8598
  var RESERVED_FIELDS = ["id", "created_at", "updated_at", "deleted_at", "state"];
8637
8599
  var RESERVED_FIELD_SET = new Set(RESERVED_FIELDS);
8638
- var FIELD_TYPES = ["tinyint", "smallint", "mediumint", "int", "bigint", "decimal", "float", "double", "char", "varchar", "enum", "tinytext", "text", "mediumtext", "longtext", "datetime", "json"];
8600
+ var FIELD_TYPES = ["tinyint", "smallint", "mediumint", "int", "bigint", "decimal", "float", "double", "char", "varchar", "enum", "tinytext", "text", "mediumtext", "longtext", "datetime", "timestamp", "json"];
8639
8601
  var FIELD_TYPE_SET = new Set(FIELD_TYPES);
8640
8602
  var INPUT_TYPES = ["number", "integer", "string", "char", "array", "array_number", "array_integer", "json", "json_number", "json_integer"];
8641
8603
  var INPUT_TYPE_SET = new Set(INPUT_TYPES);
@@ -8845,21 +8807,21 @@ async function checkTable(tables, config2) {
8845
8807
  Logger.warn(`${tablePrefix}${fileName} \u6587\u4EF6 ${colKey} \u4E3A ${effectiveType} \u7C7B\u578B\uFF0C\u4E0D\u652F\u6301\u552F\u4E00\u7EA6\u675F\uFF08unique=true \u65E0\u6548\uFF09`);
8846
8808
  hasError = true;
8847
8809
  }
8848
- } else if (effectiveType === "datetime") {
8810
+ } else if (effectiveType === "datetime" || effectiveType === "timestamp") {
8849
8811
  if (field.min !== undefined && field.min !== null) {
8850
- Logger.warn(`${tablePrefix}${fileName} \u6587\u4EF6 ${colKey} \u4E3A datetime \u7C7B\u578B\uFF0Cmin \u5FC5\u987B\u4E3A null\uFF0C\u5F53\u524D\u4E3A "${field.min}"`);
8812
+ Logger.warn(`${tablePrefix}${fileName} \u6587\u4EF6 ${colKey} \u4E3A ${effectiveType} \u7C7B\u578B\uFF0Cmin \u5FC5\u987B\u4E3A null\uFF0C\u5F53\u524D\u4E3A "${field.min}"`);
8851
8813
  hasError = true;
8852
8814
  }
8853
8815
  if (field.max !== undefined && field.max !== null) {
8854
- Logger.warn(`${tablePrefix}${fileName} \u6587\u4EF6 ${colKey} \u4E3A datetime \u7C7B\u578B\uFF0Cmax \u5FC5\u987B\u4E3A null\uFF0C\u5F53\u524D\u4E3A "${field.max}"`);
8816
+ Logger.warn(`${tablePrefix}${fileName} \u6587\u4EF6 ${colKey} \u4E3A ${effectiveType} \u7C7B\u578B\uFF0Cmax \u5FC5\u987B\u4E3A null\uFF0C\u5F53\u524D\u4E3A "${field.max}"`);
8855
8817
  hasError = true;
8856
8818
  }
8857
8819
  if (field.default !== undefined && field.default !== null) {
8858
- Logger.warn(`${tablePrefix}${fileName} \u6587\u4EF6 ${colKey} \u4E3A datetime \u7C7B\u578B\uFF0C\u9ED8\u8BA4\u503C\u5FC5\u987B\u4E3A null\uFF08\u5982\u9700\u5F53\u524D\u65F6\u95F4\uFF0C\u8BF7\u5728\u4E1A\u52A1\u5199\u5165\u65F6\u8D4B\u503C\uFF09\u3002\u5F53\u524D\u4E3A ${formatValuePreview(field.default)}`);
8820
+ Logger.warn(`${tablePrefix}${fileName} \u6587\u4EF6 ${colKey} \u4E3A ${effectiveType} \u7C7B\u578B\uFF0C\u9ED8\u8BA4\u503C\u5FC5\u987B\u4E3A null\uFF08\u5982\u9700\u5F53\u524D\u65F6\u95F4\uFF0C\u8BF7\u5728\u4E1A\u52A1\u5199\u5165\u65F6\u8D4B\u503C\uFF09\u3002\u5F53\u524D\u4E3A ${formatValuePreview(field.default)}`);
8859
8821
  hasError = true;
8860
8822
  }
8861
8823
  if (field.unsigned !== undefined) {
8862
- Logger.warn(`${tablePrefix}${fileName} \u6587\u4EF6 ${colKey} \u4E3A datetime \u7C7B\u578B\uFF0C\u4E0D\u5141\u8BB8\u8BBE\u7F6E unsigned`);
8824
+ Logger.warn(`${tablePrefix}${fileName} \u6587\u4EF6 ${colKey} \u4E3A ${effectiveType} \u7C7B\u578B\uFF0C\u4E0D\u5141\u8BB8\u8BBE\u7F6E unsigned`);
8863
8825
  hasError = true;
8864
8826
  }
8865
8827
  } else if (effectiveType === "enum") {
@@ -10606,6 +10568,7 @@ class SyncTable {
10606
10568
  varchar: "VARCHAR",
10607
10569
  enum: "ENUM",
10608
10570
  datetime: "DATETIME",
10571
+ timestamp: "TIMESTAMP",
10609
10572
  tinytext: "TINYTEXT",
10610
10573
  text: "MEDIUMTEXT",
10611
10574
  mediumtext: "MEDIUMTEXT",
@@ -10706,6 +10669,7 @@ class SyncTable {
10706
10669
  }
10707
10670
  }
10708
10671
  SyncTable.throwIfIncompatibleTypeChanges(incompatibleTypeChanges);
10672
+ const createdTables = [];
10709
10673
  for (const task of tableTasks) {
10710
10674
  const item = task.item;
10711
10675
  const tableName = task.tableName;
@@ -10745,6 +10709,7 @@ class SyncTable {
10745
10709
  }
10746
10710
  } else {
10747
10711
  await SyncTable.createTable(this.db, tableName, tableFields);
10712
+ createdTables.push(tableName);
10748
10713
  }
10749
10714
  } catch (error) {
10750
10715
  const errMsg = String(error?.message || error);
@@ -10767,6 +10732,17 @@ class SyncTable {
10767
10732
  throw error;
10768
10733
  }
10769
10734
  }
10735
+ if (createdTables.length > 0) {
10736
+ const lines = [];
10737
+ lines.push(`\u521B\u5EFA\u8868\u5217\u8868\uFF08\u5171${createdTables.length}\u5F20\uFF09:`);
10738
+ for (const tableName of createdTables) {
10739
+ lines.push(`- ${tableName}`);
10740
+ }
10741
+ const text = lines.join(`
10742
+ `);
10743
+ Logger.debug(text, { truncate: false, console: false });
10744
+ Logger.printPlainLines(text, { stream: "stdout" });
10745
+ }
10770
10746
  } catch (error) {
10771
10747
  if (error?.__syncTableLogged === true) {
10772
10748
  throw error;
@@ -10879,6 +10855,8 @@ class SyncTable {
10879
10855
  return "null";
10880
10856
  case "datetime":
10881
10857
  return "null";
10858
+ case "timestamp":
10859
+ return "null";
10882
10860
  case "tinytext":
10883
10861
  case "text":
10884
10862
  case "mediumtext":
@@ -10906,7 +10884,7 @@ class SyncTable {
10906
10884
  return ` DEFAULT '${escaped}'`;
10907
10885
  }
10908
10886
  }
10909
- if (normalizedType === "datetime") {
10887
+ if (normalizedType === "datetime" || normalizedType === "timestamp") {
10910
10888
  if (typeof actualDefault === "string") {
10911
10889
  const trimmed = actualDefault.trim();
10912
10890
  if (/^current_timestamp(\(\s*\d+\s*\)|\(\s*\))?$/i.test(trimmed)) {
@@ -11445,7 +11423,6 @@ SQL: ${sqlLine}
11445
11423
  ${cols}
11446
11424
  ) ENGINE=${ENGINE} DEFAULT CHARSET=${CHARSET} COLLATE=${COLLATE}`;
11447
11425
  await db.unsafe(createSQL);
11448
- Logger.debug(`[\u8868 ${tableName}] + \u521B\u5EFA\u8868\uFF08\u7CFB\u7EDF\u5B57\u6BB5 + \u4E1A\u52A1\u5B57\u6BB5\uFF09`);
11449
11426
  const indexClauses = [];
11450
11427
  for (const sysField of systemIndexFields) {
11451
11428
  const indexName = `idx_${sysField}`;
@@ -13447,13 +13424,15 @@ class Validator {
13447
13424
  }
13448
13425
  case "string": {
13449
13426
  if (typeof value === "string") {
13450
- if (String(dbType || "").toLowerCase() === "datetime") {
13427
+ const dbTypeNormalized2 = String(dbType || "").toLowerCase();
13428
+ if (dbTypeNormalized2 === "datetime" || dbTypeNormalized2 === "timestamp") {
13451
13429
  const trimmed = value.trim();
13452
13430
  return { value: trimmed, error: null };
13453
13431
  }
13454
13432
  return { value, error: null };
13455
13433
  }
13456
- if (String(dbType || "").toLowerCase() === "datetime") {
13434
+ const dbTypeNormalized = String(dbType || "").toLowerCase();
13435
+ if (dbTypeNormalized === "datetime" || dbTypeNormalized === "timestamp") {
13457
13436
  return { value: null, error: "\u5FC5\u987B\u662F\u65F6\u95F4\u5B57\u7B26\u4E32" };
13458
13437
  }
13459
13438
  return { value: null, error: "\u5FC5\u987B\u662F\u5B57\u7B26\u4E32" };
@@ -13495,7 +13474,8 @@ class Validator {
13495
13474
  return { value: null, error: "\u5FC5\u987B\u662FJSON\u5BF9\u8C61\u6216\u6570\u7EC4" };
13496
13475
  return checkJsonLeaves(value, "integer") ? { value, error: null } : { value: null, error: "JSON\u503C\u5FC5\u987B\u662F\u6574\u6570" };
13497
13476
  default: {
13498
- if (String(dbType || "").toLowerCase() === "datetime") {
13477
+ const dbTypeNormalized = String(dbType || "").toLowerCase();
13478
+ if (dbTypeNormalized === "datetime" || dbTypeNormalized === "timestamp") {
13499
13479
  if (typeof value !== "string")
13500
13480
  return { value: null, error: "\u5FC5\u987B\u662F\u65F6\u95F4\u5B57\u7B26\u4E32" };
13501
13481
  const trimmed = value.trim();
@@ -13552,7 +13532,8 @@ class Validator {
13552
13532
  if (!isJsonStructure(value))
13553
13533
  return "\u5FC5\u987B\u662FJSON\u5BF9\u8C61\u6216\u6570\u7EC4";
13554
13534
  }
13555
- if (String(type || "").toLowerCase() === "datetime") {
13535
+ const normalizedTypeForDb = String(type || "").toLowerCase();
13536
+ if (normalizedTypeForDb === "datetime" || normalizedTypeForDb === "timestamp") {
13556
13537
  if (typeof value !== "string")
13557
13538
  return "\u5FC5\u987B\u662F\u65F6\u95F4\u5B57\u7B26\u4E32";
13558
13539
  if (!/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/.test(value))
@@ -13621,7 +13602,7 @@ class Validator {
13621
13602
  return defaultValue;
13622
13603
  }
13623
13604
  const normalizedType = String(type || "").toLowerCase();
13624
- if (normalizedType === "datetime" || normalizedType === "json" || normalizedType === "enum") {
13605
+ if (normalizedType === "datetime" || normalizedType === "timestamp" || normalizedType === "json" || normalizedType === "enum") {
13625
13606
  return null;
13626
13607
  }
13627
13608
  const normalizedInput = String(input || "").toLowerCase();
@@ -16898,21 +16879,6 @@ class Befly {
16898
16879
  noLog = true;
16899
16880
  }
16900
16881
  }
16901
- const writePlainLinesToConsole = (prefix, errName, message) => {
16902
- const text = String(message || "");
16903
- const parts = text.split(`
16904
- `);
16905
- const firstLine = parts.length > 0 ? String(parts[0] || "") : "";
16906
- const head = `[${prefix}] \u542F\u52A8\u5931\u8D25: ${errName}: ${firstLine}`;
16907
- try {
16908
- process.stderr.write(`${head}
16909
- `);
16910
- for (let i = 1;i < parts.length; i = i + 1) {
16911
- process.stderr.write(`${parts[i]}
16912
- `);
16913
- }
16914
- } catch {}
16915
- };
16916
16882
  if (!alreadyLogged && multiline) {
16917
16883
  const appName = String(this.config?.appName || "\u9879\u76EE");
16918
16884
  const errName = error instanceof Error && error.name ? error.name : "Error";
@@ -16921,7 +16887,18 @@ class Befly {
16921
16887
  errorKind: kind,
16922
16888
  errorMessage: errMessage
16923
16889
  }, { truncate: false, console: false });
16924
- writePlainLinesToConsole(appName, errName, errMessage);
16890
+ {
16891
+ const text = String(errMessage || "");
16892
+ const parts = text.split(`
16893
+ `);
16894
+ const firstLine = parts.length > 0 ? String(parts[0] || "") : "";
16895
+ const lines = [];
16896
+ lines.push(`[${appName}] \u542F\u52A8\u5931\u8D25: ${errName}: ${firstLine}`);
16897
+ for (let i = 1;i < parts.length; i = i + 1) {
16898
+ lines.push(String(parts[i] || ""));
16899
+ }
16900
+ Logger.printPlainLines(lines, { stream: "stderr" });
16901
+ }
16925
16902
  } else if (alreadyLogged) {
16926
16903
  Logger.error({
16927
16904
  msg: "\u9879\u76EE\u542F\u52A8\u5931\u8D25\uFF08\u4E0B\u5C42\u5DF2\u8BB0\u5F55\uFF09",