From 2982482f25ce13afad6194af66a93a69e2ce39ef Mon Sep 17 00:00:00 2001 From: Eric Fontana Date: Tue, 20 Jan 2015 09:06:36 -0500 Subject: [PATCH] More doc updates --- README.md | 3 + TimberWinR/Inputs/LogsListener.cs | 142 +----------------------------- TimberWinR/TimberWinR.csproj | 1 + TimberWinR/mdocs/StdinInput.md | 9 +- 4 files changed, 11 insertions(+), 144 deletions(-) diff --git a/README.md b/README.md index 07f5ee3..5e4d9e1 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,9 @@ Please use the TimberWinR Google Group for discussion and support: https://groups.google.com/forum/#!forum/timberwinr +Latest Build: + +![alt tag](https://ci.appveyor.com/api/projects/status/github/Cimpress-MCP/TimberWinR) ## Inputs The current supported Input format sources are: diff --git a/TimberWinR/Inputs/LogsListener.cs b/TimberWinR/Inputs/LogsListener.cs index 65a07f2..8459b21 100644 --- a/TimberWinR/Inputs/LogsListener.cs +++ b/TimberWinR/Inputs/LogsListener.cs @@ -21,147 +21,7 @@ using LogRecordSet = Interop.MSUtil.ILogRecordset; using TimberWinR.Parser; namespace TimberWinR.Inputs -{ - public class LogsFileDatabase - { - private static readonly object _locker = new object(); - private List Entries { get; set; } - private string DatabaseDirectory { get; set; } - public string DatabaseFileName - { - get { return Path.Combine(DatabaseDirectory, ".timberwinrdb"); } - } - - public static Manager Manager { get; set; } - - private static LogsFileDatabase instance; - - private bool ExistingFile(string logName) - { - lock (_locker) - { - return ExistingFileTest(logName); - } - } - - private bool ExistingFileTest(string logName) - { - var existingEntry = (from e in Entries where e.FileName == logName select e).FirstOrDefault(); - return existingEntry != null; - } - - private void RemoveFileEntry(string logName) - { - lock (_locker) - { - var existingEntry = (from e in Entries where e.FileName == logName select e).FirstOrDefault(); - if (existingEntry != null) - { - Entries.Remove(existingEntry); - WriteDatabaseFileNoLock(); - } - } - } - - private LogsFileDatabaseEntry AddFileEntry(string logName, TextLineInputFormat fmt) - { - LogsFileDatabaseEntry de = new LogsFileDatabaseEntry(); - lock (_locker) - { - var lq = new LogQuery(); - FileInfo fi = new FileInfo(logName); - de.FileName = logName; - de.Size = fi.Length; - de.SampleTime = DateTime.UtcNow; - de.CreationTime = fi.CreationTimeUtc; - if (fi.Exists) - { - var qcount = string.Format("SELECT max(Index) as MaxRecordNumber FROM {0}", logName); - var rcount = lq.Execute(qcount, fmt); - var qr = rcount.getRecord(); - var lrn = (Int64)qr.getValueEx("MaxRecordNumber"); - de.MaxRecords = lrn; - } - Entries.Add(de); - WriteDatabaseFileNoLock(); - } - return de; - } - - public static LogsFileDatabaseEntry AddLogFile(string logName, TextLineInputFormat fmt) - { - Instance.RemoveFileEntry(logName); // Remove if already exists, otherwise ignores. - return Instance.AddFileEntry(logName, fmt); - } - - public static LogsFileDatabase Instance - { - get - { - if (instance == null) - { - instance = new LogsFileDatabase(Manager.LogfileDir); - lock (_locker) - { - if (!Directory.Exists(instance.DatabaseDirectory)) - { - Directory.CreateDirectory(instance.DatabaseDirectory); - } - if (File.Exists(instance.DatabaseFileName)) - instance.ReadDatabaseNoLock(); - else - instance.WriteDatabaseFileNoLock(); - } - } - return instance; - } - } - - private void ReadDatabaseNoLock() - { - JsonSerializer serializer = new JsonSerializer(); - if (File.Exists(DatabaseFileName)) - Entries = JsonConvert.DeserializeObject>(File.ReadAllText(DatabaseFileName)); - } - private void WriteDatabaseFileNoLock() - { - File.WriteAllText(DatabaseFileName, JsonConvert.SerializeObject(instance.Entries), Encoding.UTF8); - } - - - private void ReadDatabaseLock() - { - lock (_locker) - { - ReadDatabaseNoLock(); - } - - } - private void WriteDatabaseLock() - { - lock (_locker) - { - WriteDatabaseFileNoLock(); - } - } - - private LogsFileDatabase(string databaseDirectory) - { - DatabaseDirectory = databaseDirectory; - Entries = new List(); - } - - } - - public class LogsFileDatabaseEntry - { - public string FileName { get; set; } - public Int64 MaxRecords { get; set; } - public DateTime CreationTime { get; set; } - public DateTime SampleTime { get; set; } - public long Size { get; set; } - } - +{ /// /// Tail a file. /// diff --git a/TimberWinR/TimberWinR.csproj b/TimberWinR/TimberWinR.csproj index 323fb71..16328c6 100644 --- a/TimberWinR/TimberWinR.csproj +++ b/TimberWinR/TimberWinR.csproj @@ -87,6 +87,7 @@ + diff --git a/TimberWinR/mdocs/StdinInput.md b/TimberWinR/mdocs/StdinInput.md index 580ef8e..d412726 100644 --- a/TimberWinR/mdocs/StdinInput.md +++ b/TimberWinR/mdocs/StdinInput.md @@ -3,7 +3,12 @@ The Stdin Input will read from the console (Console.ReadLine) and build a simple message for testing. ## Parameters -There are no Parameters at this time. +The following parameters are allowed when configuring WindowsEvents. + +| Parameter | Type | Description | Details | Default | +| :---------------- |:---------------| :----------------------------------------------------------------------- | :--------------------------- | :-- | +| [codec](https://github.com/Cimpress-MCP/TimberWinR/blob/master/TimberWinR/mdocs/Codec.md) | object | Codec to use | + ```json { @@ -26,5 +31,3 @@ A field: "type": "Win32-Stdin" is automatically appended, and the entire JSON is | ---- |:-----| :-----------------------------------------------------------------------| | type | STRING |Win32-Stdin | | message | STRING | The message typed in | -| [codec](https://github.com/Cimpress-MCP/TimberWinR/blob/master/TimberWinR/mdocs/Codec.md) | object | Codec to use | -