forked from connamara/quickfixn
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'composite_log' of github.com:roji/quickfixn into compos…
…ite_log_180
- Loading branch information
Showing
3 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
| ||
namespace QuickFix | ||
{ | ||
/// <summary> | ||
/// File log implementation | ||
/// </summary> | ||
internal class CompositeLog : ILog | ||
{ | ||
private ILog[] logs_; | ||
|
||
public CompositeLog(ILog[] logs) | ||
{ | ||
logs_ = logs; | ||
} | ||
|
||
public void Clear() | ||
{ | ||
foreach (var log in logs_) | ||
log.Clear(); | ||
} | ||
|
||
public void OnIncoming(string msg) | ||
{ | ||
foreach (var log in logs_) | ||
log.OnIncoming(msg); | ||
} | ||
|
||
public void OnOutgoing(string msg) | ||
{ | ||
foreach (var log in logs_) | ||
log.OnOutgoing(msg); | ||
} | ||
|
||
public void OnEvent(string s) | ||
{ | ||
foreach (var log in logs_) | ||
log.OnEvent(s); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace QuickFix | ||
{ | ||
/// <summary> | ||
/// Allows multiple log factories to be used with QuickFIX/N. For example, you could log events to the console and also log all events and messages to a file. | ||
/// </summary> | ||
public class CompositeLogFactory : ILogFactory | ||
{ | ||
private ILogFactory[] factories_; | ||
|
||
public CompositeLogFactory(ILogFactory[] factories) | ||
{ | ||
factories_ = factories; | ||
} | ||
|
||
/// <summary> | ||
/// Creates a composite log | ||
/// </summary> | ||
/// <param name="sessionID">session ID for the message store</param> | ||
/// <returns></returns> | ||
public ILog Create(SessionID sessionID) | ||
{ | ||
return new CompositeLog(factories_.Select(f => f.Create(sessionID)).ToArray()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters