[译]Win32的尾部-Unix'tail -f'的Windows版本
By robot-v1.0
本文链接 https://www.kyfws.com/applications/tail-for-win32-a-windows-version-of-the-unix-tail-zh/
版权声明 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
- 5 分钟阅读 - 2095 个词 阅读量 0[译]Win32的尾部-Unix’tail -f’的Windows版本
原文地址:https://www.codeproject.com/Articles/5441/Tail-for-Win32-A-Windows-version-of-the-Unix-tail
原文作者:Paul Perkins
译文由本站 robot-v1.0 翻译
前言
I had searched for what seemed like an eternity for a Windows version of the ‘tail -f’ command - a way to monitor logfiles as they change in realitime. Having not found one, I decided to write my own. Tail for Win32 is the result of hundreds of evenings' work to achieve just that.
我已经在Windows版本的" tail -f"命令中寻找了永恒的东西-一种实时监视日志文件的方法.没有找到一个,我决定写自己的. Win32的尾巴是数百个晚上的工作成果的结果.
介绍(Introduction)
是否曾经想在Windows上仅键入" tail -f error_log"?(Ever wanted to just type ‘tail -f error_log’ on Windows?)
羡慕您的Unix朋友谁能实时跟踪文件更改的发生?(Envious of your Unix friends who can track changes to a file, in real time, as they happen?)
好了,现在有了Win32的Objektiv Tail,您将可以像以前从未有过的那样愉快地监视日志文件.(Well, now with the Objektiv Tail for Win32, you’ll be happily monitoring your log files like you’ve never done before.)
更好的是,您可以使用获得专利的"多重文档界面" TM技术同时跟踪多个文件,每个文件都有自己的精美窗口.(What’s even better, you can track several files all at the same time with the patented “Multiple Document Interface"TM technology, with each file having its own, fabulous window.)
它是什么?(What is it?)
Tail for Win32是Unix” tail"实用程序的Windows版本.它可以用于实时监视文本文件的更改-非常适合查看错误日志.(Tail for Win32 is a Windows version of the Unix ‘tail’ utility. It can be used to monitor changes to a text file in real time - ideal for watching error logs.)
该程序是使用MFC用C ++编写的,并使用Win32文件更改通知来监视文件更改的时间.(The program was written in C++ using MFC, and uses Win32 file change notifications to monitor when a file changes.)
该应用程序使用"插件"架构,在该架构下,所有更改都通过可执行各种功能的外部DLL传递.(The application uses a ‘plug-in’ architecture, under which all changes are passed through external DLLs that can perform various functionality.)
第一个插件是SMTP过滤器.在受监视文件中找到关键字时,此DLL通过SMTP发送电子邮件.(The first plug-in is an SMTP filter. This DLL sends emails via SMTP when a keyword is found in the file being monitored.)
和?…(And?…)
除了实时监视文件之外,您还可以指定尾巴需要的一组"关键字".遇到关键字时,可以用多种可选颜色突出显示"语法",还可以触发外部插件.这都是可以即时配置的.(As well as monitoring files in real time, you can also specify a set of ‘keywords’ that tail looks out for. When a keyword is encountered, it can be ‘syntax’ highlighted in a number of optional colors, and can also fire external plug-ins. This is all configurable on the fly.)
也可以告诉程序忽略不包含指定关键字的任何行;只显示"热"线.(The program can also be told to ignore any lines that do not contain the keywords specified; only showing ‘hot’ lines.)
那么它是怎样工作的?(So How Does it Work?)
该应用程序的核心是Win32文件通知API.每当目录中的文件更改时,此API都会触发事件.使用此事件,我们可以跟踪对特定文件进行的更改.(At the core of the application is the Win32 file notification API. This API fires an event whenever a file changes in a directory. Using this event, we can track whenever changes are made to a particular file.)
对于每个受监视的文件,都会设置一个线程,该线程在触发文件通知时会阻塞.这使应用程序极为高效-仅在文件实际更改时才执行任何操作.(For each file that is monitored, a thread is set up that blocks on the firing of the file notification. This makes the application extremely efficient - it only ever does anything when a file actually changes.)
这些都是在Visual Studio 6下用MFC编写的.但是在.NET和.NET 2003下可以很愉快地进行编译.(This is all written in MFC under Visual Studio 6. But compiles quite happily under .NET and .NET 2003.)
或多或少地使用以下控件:(The following controls are used to a greater or lesser degree:)
RichText
control -version 2.0以允许背景阴影(control -version 2.0 to allow background shading)ListView
控件-带有复选框和组合控件(control - with checkboxes and combo controls)Tree
控件-子类化以处理双击和右键单击(control - subclassed to handle double-clicks and right-clicks)
我能帮忙吗?(Can I Help?)
是的,请!(Yes, please!)
该项目托管在SourceForge上,因此CVS访问是所有交易的一部分.如果您认为自己愿意提供帮助,甚至可以花几分钟的时间做出贡献,请与我们取得联系!(The project is hosted on SourceForge, so CVS access is all part of the deal. If you think you’d like to help and can contribute even a few minutes of your time, please do get in touch!)
项目主页为:(The project homepage is:) 这里(here) 并且CVS信息库至少每天更新一次,因此请定期进行检查.(and the CVS repository is updated at least daily, so please do check back on a regular basis.)
执照(License)
尾巴根据GPL释放.简而言之,您可以随心所欲地使用源代码,只要您免费或牟利地传递应用程序,您还必须传递源代码.(Tail is released under the GPL. In a nutshell, you can do whatever you like with the source, so long as if you pass on the application for free or for profit, you must also pass on the source.)
更新(Updates)
- 4.2.7:提示窗口修复.添加了背景和突出显示颜色对话框.稍微重新调整对象模型.(4.2.7: Tally window fix. Added background and highlight colour dialogs. Slight re-jig of the object model.)
- 4.2.6:修复了Tally窗口和Keyword configuration窗口中的一些错误.(4.2.6: Fixed a couple of bugs with the Tally window and the Keyword configuration window.)
许可
本文以及所有相关的源代码和文件均已获得The Code Project Open License (CPOL)的许可。
VC7.0 VC7.1 C++ VC6 WinXP Win2003 Win2K MFC Visual-Studio Dev 新闻 翻译