V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Tumblr
V2EX  ›  中州韻

Windows 下清理小狼毫(Weasel)的日志文件

  •  1
     
  •   Tumblr · 2019-06-25 10:31:26 +08:00 · 7832 次点击
    这是一个创建于 1738 天前的主题,其中的信息可能已经有所发展或是发生改变。

    初用小狼毫的时候,你需要进行各种配置、调试,以达到最合适你的使用习惯。
    当然,调试的时候要看日志,但是呢,Weasel 产生的日志并不是那么容易识别,并不太容易知道我要看哪个。

    于是乎……先清理一下,再来调试吧。
    Weasel 的日志是保存在系统的临时目录中的,都是以 rime 开头的文本文件。在 Windows 下,如果直接删除,会提示文件被占用,有部分文件无法删除。
    那么,我们就先把小狼毫的进程停掉,再来删除。

    function Remove-WeaselLogs {
        $rime_exec = (Get-Process -Name WeaselServer).Path
        Write-Host -ForegroundColor DarkYellow "Stopping IME service..."
        Stop-Process -Name WeaselServer
        Start-Sleep -Seconds 1
        Remove-Item $env:TEMP\rime* -Force -Confirm:$false
        Write-Host -ForegroundColor Green "Weasel logs have been purged."
        Start-Process $rime_exec
    }
    

    运行函数 Remove-WeaselLogs ,即可清理 Weasel 的已有日志,调试的时候就方便找到对应的日志文件了。

    第 1 条附言  ·  2019-06-25 13:41:37 +08:00

    之前有个问题没考虑到,就是本来这个进程没有运行,就会报错了,且重新启动不成功,稍微做了下优化:

    function Remove-WeaselLogs {
        Write-Host -ForegroundColor DarkYellow "Stopping IME service..."
        $rime_proc = Get-Process -Name WeaselServer -ErrorAction SilentlyContinue -ErrorVariable Proc_Check
        if ( $Proc_Check ) {
            $rime_exec = (Get-ChildItem -Path 'C:\Program Files\Rime\' -Recurse -Include WeaselServer.exe).FullName
        }
        else {
            $rime_exec = $rime_proc.Path
            Stop-Process -Name WeaselServer
        }
        Start-Sleep -Seconds 1
        Remove-Item $env:TEMP\rime* -Force -Confirm:$false
        Write-Host -ForegroundColor Green "Weasel logs have been purged."
        Start-Process $rime_exec
    }
    
    2 条回复    2019-06-25 13:43:18 +08:00
    runze
        1
    runze  
       2019-06-25 10:55:36 +08:00
    pwsh 虽然用着蛋疼,但是看起来真舒服
    Tumblr
        2
    Tumblr  
    OP
       2019-06-25 13:43:18 +08:00
    @runze #1 是啊,pwsh 的易读性没得说。
    很多人吐槽 pwsh 的函数太长了,其实……没几个人会完整写的吧。。。都是 tab 自动补全了。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2850 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 15:20 · PVG 23:20 · LAX 08:20 · JFK 11:20
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.