Skip to content
This repository has been archived by the owner on Apr 3, 2024. It is now read-only.

Commit

Permalink
add logs. exe now in github release
Browse files Browse the repository at this point in the history
  • Loading branch information
fredericrous committed Aug 18, 2015
1 parent 39eb21c commit d69d305
Show file tree
Hide file tree
Showing 18 changed files with 365 additions and 26 deletions.
216 changes: 216 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.

# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates

# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs

# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
build/
bld/
[Bb]in/
[Oo]bj/

# Visual Studio 2015 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/

# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*

# NUNIT
*.VisualState.xml
TestResult.xml

# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c

# DNX
project.lock.json
artifacts/

*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc

# Chutzpah Test files
_Chutzpah*

# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile

# Visual Studio profiler
*.psess
*.vsp
*.vspx

# TFS 2012 Local Workspace
$tf/

# Guidance Automation Toolkit
*.gpState

# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user

# JustCode is a .NET coding add-in
.JustCode

# TeamCity is a build add-in
_TeamCity*

# DotCover is a Code Coverage Tool
*.dotCover

# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*

# MightyMoose
*.mm.*
AutoTest.Net/

# Web workbench (sass)
.sass-cache/

# Installshield output folder
[Ee]xpress/

# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html

# Click-Once directory
publish/

# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Comment the next line if you want to checkin your web deploy settings
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj

# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config

# Windows Azure Build Output
csx/
*.build.csdef

# Windows Store app package directory
AppPackages/

# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/

# Others
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.pfx
*.publishsettings
node_modules/
orleans.codegen.cs

# RIA/Silverlight projects
Generated_Code/

# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm

# SQL Server files
*.mdf
*.ldf

# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings

# Microsoft Fakes
FakesAssemblies/

# Node.js Tools for Visual Studio
.ntvs_analysis.dat

# Visual Studio 6 build log
*.plg

# Visual Studio 6 workspace options file
*.opt

# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
Binary file removed LyncLogger.exe
Binary file not shown.
File renamed without changes.
Binary file added LyncLogger.v11.suo
Binary file not shown.
37 changes: 37 additions & 0 deletions LyncLogger/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>

<log4net
xsi:noNamespaceSchemaLocation="http://csharptest.net/downloads/schema/log4net.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<appender name="TraceAppender" type="log4net.Appender.TraceAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%5level [%thread] (%file:%line) - %message%newline"/>
</layout>
</appender>

<appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
<file value="LyncLogger.log" />
<appendToFile value="true" />
<maximumFileSize value="100KB" />
<maxSizeRollBackups value="2" />

<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%5level [%thread] (%file:%line) - %message%newline" />
</layout>
</appender>

<root>
<level value="DEBUG" />
<appender-ref ref="TraceAppender" />
<appender-ref ref="RollingFile" />
</root>
</log4net>

<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>
29 changes: 23 additions & 6 deletions src/LyncLogger/LyncLogger.cs → LyncLogger/LyncLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using System.Windows.Forms;
using System.ComponentModel;
using System.Reflection;
using log4net;

namespace LyncLogger
{
Expand All @@ -25,12 +26,14 @@ class LyncLogger
private static DirectoryInfo _folderLog;
private static string _fileLog;

private static readonly ILog _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);

public LyncLogger(string folderLog)
{
_folderLog = new DirectoryInfo(folderLog);
_fileLog = Path.Combine(folderLog, "conversation_{0}_{1}.log");

run();
run();
}

/// <summary>
Expand All @@ -43,13 +46,13 @@ public void run()
{
//Start the conversation
LyncClient client = LyncClient.GetClient();



//handles the states of the logger displayed in the systray
client.StateChanged += (s, e) =>
{
if (e.NewState == ClientState.SignedOut)
{
_log.Info("User signed out. Watch for signed in event");
NotifyIconSystray.ChangeLoggerStatus(false);
run();
}
Expand All @@ -60,41 +63,53 @@ public void run()
//listen on conversation in order to log messages
ConversationManager conversations = client.ConversationManager;

//check our listener hasn't
//check our listener is not already registered
var handler = typeof(ConversationManager).GetField("ConversationAdded", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(conversations) as Delegate;

if (handler == null)
{
_log.Info("watch conversation");
conversations.ConversationAdded += conversations_ConversationAdded;
NotifyIconSystray.ChangeLoggerStatus(true);
}
else
{
_log.Info("Conversation already in watching state");
_log.Info(handler);
}

}
else
{
_log.Info("Not signed in. Watch for signed in event");
Thread.Sleep(DELAY_RETRY_AUTHENTICATION / 10);
run();
}

}
catch (LyncClientException lyncClientException)
{
Console.Out.WriteLine(lyncClientException);
if (lyncClientException.Message.Equals(EXCEPTION_LYNC_NOCLIENT))
{
_log.Info("Lync Known Exception: no client");
Thread.Sleep(DELAY_RETRY_AUTHENTICATION);
run();
}
else
{
_log.Warn("Lync Exception", lyncClientException);
}
}
catch (SystemException systemException)
{
if (IsLyncException(systemException))
{
// Log the exception thrown by the Lync Model API.
Console.WriteLine("Error: " + systemException);
_log.Warn("Lync Exception", systemException);
}
else
{
_log.Warn("Exception: ", systemException);
// Rethrow the SystemException which did not come from the Lync Model API.
throw;
}
Expand Down Expand Up @@ -145,6 +160,7 @@ static void conversations_ConversationAdded(object sender, ConversationManagerEv
//detect all messages (including user's)
remoteImModality.InstantMessageReceived += (__sender, __e) =>
{
_log.Info("message event: " + __e.Text);
remoteImModality_InstantMessageReceived(__sender, __e, fileLog);
};
};
Expand All @@ -154,6 +170,7 @@ static void conversations_ConversationAdded(object sender, ConversationManagerEv
//notify call
callImModality.ModalityStateChanged += (_sender, _e) =>
{
_log.Info("call event: " + _e.NewState);
callImModality_ModalityStateChanged(_e, fileLog);
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,13 @@
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Reference Include="log4net, Version=1.2.13.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\log4net.2.0.3\lib\net40-full\log4net.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Lync.Model, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<EmbedInteropTypes>False</EmbedInteropTypes>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand All @@ -72,6 +77,7 @@
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.5">
Expand Down
File renamed without changes.
Loading

0 comments on commit d69d305

Please sign in to comment.