dsh-notify-say 0.4.33 → 0.4.34

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/dsh-notify.ps1 CHANGED
@@ -52,6 +52,12 @@ param(
52
52
  [string]$VoiceRoot = '',
53
53
  # 用户语音包根目录(可写),仅用于诊断日志。
54
54
  [string]$UserVoiceRoot = '',
55
+ # v0.4.34:日志级别。info(默认)= 只记元数据;debug = 记标题与正文。
56
+ #
57
+ # 为什么需要:日志会写进 %TEMP%,用户提 Issue 时经常直接上传。
58
+ # 标题与正文可能含项目名、人名,对诊断「为什么不响」却没帮助。
59
+ [ValidateSet('info', 'debug')]
60
+ [string]$LogLevel = 'info',
55
61
  # v0.4.16:数字增益倍数(1.0 = 原样;2.0 = 放大一倍)。
56
62
  #
57
63
  # 为什么需要:实测本包 247 个语音包峰值中位仅 **40.4%**
@@ -281,6 +287,23 @@ try {
281
287
  $logDir = Join-Path ([System.IO.Path]::GetTempPath()) 'dsh-notify-say'
282
288
  if (-not (Test-Path -LiteralPath $logDir)) { New-Item -ItemType Directory -Force -Path $logDir | Out-Null }
283
289
  $logFile = Join-Path $logDir 'notify.log'
290
+
291
+ # v0.4.34:写一行日志。$detail = 含用户内容(标题/正文),只在 debug 档写。
292
+ #
293
+ # 用函数而不是内联 Add-Content:三处调用点都要同样判断,
294
+ # 内联会让"某处忘了判断"这种遗漏很难看出来。
295
+ function Write-NotifyLog([string]$KindTag, [string]$Extra, [string]$Detail) {
296
+ if (-not $logFile) { return }
297
+ try {
298
+ $ts = Get-Date -Format 'yyyy-MM-dd HH:mm:ss'
299
+ $parts = @($ts, "[$KindTag]", $Extra)
300
+ if ($Detail) {
301
+ if ($LogLevel -eq 'debug') { $parts += $Detail }
302
+ else { $parts += '(内容已隐藏,需 -LogLevel debug)' }
303
+ }
304
+ Add-Content -Path $logFile -Value (($parts -join ' ').Trim()) -Encoding utf8
305
+ } catch { }
306
+ }
284
307
  # 审查建议采纳:容量护栏——超过 512KB 整文件重建(best-effort 诊断日志,不做轮转)
285
308
  if ((Test-Path -LiteralPath $logFile) -and ((Get-Item -LiteralPath $logFile -ErrorAction SilentlyContinue).Length -gt 524288)) {
286
309
  Remove-Item -LiteralPath $logFile -Force -ErrorAction SilentlyContinue
@@ -475,16 +498,16 @@ $pickedName = if ($script:playFile) { Split-Path $script:playFile -Leaf } else {
475
498
  if ($Preview) {
476
499
  if (-not $NoSound) { Play-VoiceLine }
477
500
  $soundTag = if ($NoSound) { '(静音)' } elseif ($script:lastSound) { " + 音效 $script:lastSound" } else { ' + 兜底提示音' }
478
- if ($logFile) { try { Add-Content -Path $logFile -Value ("{0} [preview] [{1}] -Voice {2} pick={3}{4}" -f (Get-Date -Format 'yyyy-MM-dd HH:mm:ss'), $Kind, $Voice, $pickedName, $soundTag) -Encoding utf8 } catch { } }
501
+ Write-NotifyLog 'preview' ("-Voice $Voice pick=$pickedName$soundTag") ''
479
502
  Write-Host ("[dsh-notify-say] OK 试听 [$Kind] pick=" + $pickedName + $soundTag) -ForegroundColor Green
480
503
  } elseif ($shown) {
481
504
  if (-not $NoSound) { Play-VoiceLine }
482
505
  $soundTag = if ($NoSound) { '(静音)' } elseif ($script:lastSound) { " + 音效 $script:lastSound" } else { ' + 兜底提示音' }
483
- if ($logFile) { try { Add-Content -Path $logFile -Value ("{0} [toast] [{1}] {2} - {3} pick={4}{5}" -f (Get-Date -Format 'yyyy-MM-dd HH:mm:ss'), $Kind, $Title, $Body, $pickedName, $soundTag) -Encoding utf8 } catch { } }
506
+ Write-NotifyLog 'toast' ("pick=$pickedName$soundTag") ("title=$Title body=$Body")
484
507
  Write-Host ("[dsh-notify-say] OK Toast [$Kind] pick=" + $pickedName + $soundTag) -ForegroundColor Green
485
508
  } else {
486
509
  if (-not $NoSound) { Play-VoiceLine }
487
510
  $soundTag = if ($NoSound) { '(静音)' } elseif ($script:lastSound) { " + 音效 $script:lastSound" } else { ' + 兜底提示音' }
488
- if ($logFile) { try { Add-Content -Path $logFile -Value ("{0} [FALLBACK] [{1}] {2} - {3} pick={4}{5}" -f (Get-Date -Format 'yyyy-MM-dd HH:mm:ss'), $Kind, $Title, $Body, $pickedName, $soundTag) -Encoding utf8 } catch { } }
511
+ Write-NotifyLog 'FALLBACK' ("pick=$pickedName$soundTag") ("title=$Title body=$Body")
489
512
  Write-Host ("[dsh-notify-say] (Toast 不可用,走兜底) [$Kind] pick=" + $pickedName + $soundTag) -ForegroundColor Yellow
490
513
  }
package/lib/client.js CHANGED
@@ -1423,6 +1423,29 @@ window.__ModuleLoader__.load({
1423
1423
  + '它依赖宿主内部结构,升级后可能失效;失效时只报错,不影响正常播报。'),
1424
1424
  ),
1425
1425
  ))
1426
+
1427
+ // ── 日志级别(v0.4.34)──────────────────────────────────────────────
1428
+ //
1429
+ // 默认 info:只记元数据(事件、音源、成败、数量)。
1430
+ // debug:额外记台词正文与 Toast 标题正文 —— **可能含敏感信息**。
1431
+ //
1432
+ // 为什么放在高级区:多数人不需要改,但排查问题时要能开。
1433
+ rows.push(h('div', { key: 'll-row', style: S.row },
1434
+ h('span', { style: S.label }, '日志详细度'),
1435
+ h('select', {
1436
+ value: v.logLevel || 'info',
1437
+ disabled: s.busy,
1438
+ onChange: function (e) { apply({ logLevel: e.target.value }, '日志级别已更新') },
1439
+ },
1440
+ h('option', { value: 'info' }, '只记元数据(默认)'),
1441
+ h('option', { value: 'debug' }, '含台词正文(可能敏感)'),
1442
+ ),
1443
+ ))
1444
+ rows.push(h('div', { key: 'll-hint', style: S.subHint },
1445
+ v.logLevel === 'debug'
1446
+ ? '⚠️ debug 档会把台词和通知正文写进日志。日志在 %TEMP%\\dsh-notify-say\\notify.log,'
1447
+ + '提 Issue 前请先切回「只记元数据」或自行删改。'
1448
+ : '日志只记事件类型、音源、成败与数量,不含台词正文。排查问题时可切到 debug。'))
1426
1449
  }
1427
1450
 
1428
1451
  if (s.msg) rows.push(h('div', { key: 'msg', style: S.ok }, s.msg))