-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add "Delete file command", improve logging
- Loading branch information
Showing
11 changed files
with
203 additions
and
65 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
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 |
---|---|---|
@@ -1,21 +1,101 @@ | ||
using System; | ||
using Loggly; | ||
using Loggly.Config; | ||
using System; | ||
using System.Diagnostics; | ||
using System.Reflection; | ||
|
||
namespace SamirBoulema.TSVN.Helpers | ||
{ | ||
|
||
public static class LogHelper | ||
{ | ||
public static void Initialize(IServiceProvider serviceProvider, string name) | ||
{ | ||
Logger.Initialize(serviceProvider, name); | ||
} | ||
private static ILogglyClient _client; | ||
private const string CustomerToken = "4a0f1123-41cd-4f9a-bca0-835914aa51d3"; | ||
private const string ApplicationName = "TSVN"; | ||
|
||
public static void Log(string message) | ||
{ | ||
#if DEBUG | ||
#if DEBUG | ||
Logger.Log(message); | ||
#endif | ||
#endif | ||
} | ||
|
||
public static ILogglyClient GetClient() | ||
{ | ||
var config = LogglyConfig.Instance; | ||
config.CustomerToken = CustomerToken; | ||
config.ApplicationName = ApplicationName; | ||
|
||
config.Transport.EndpointHostname = "logs-01.loggly.com"; | ||
config.Transport.EndpointPort = 443; | ||
config.Transport.LogTransport = LogTransport.Https; | ||
|
||
var ct = new ApplicationNameTag(); | ||
ct.Formatter = "application-{0}"; | ||
config.TagConfig.Tags.Add(ct); | ||
|
||
return new LogglyClient(); | ||
} | ||
|
||
public static void Log(Exception e) | ||
{ | ||
if (_client == null) | ||
{ | ||
_client = GetClient(); | ||
} | ||
|
||
var logEvent = new LogglyEvent(); | ||
logEvent.Data.Add("version", GetExecutingAssemblyVersion()); | ||
logEvent.Data.Add("exception", e); | ||
_client.Log(logEvent); | ||
} | ||
|
||
public static void Log(Exception e, object context) | ||
{ | ||
if (_client == null) | ||
{ | ||
_client = GetClient(); | ||
} | ||
|
||
var logEvent = new LogglyEvent(); | ||
logEvent.Data.Add("version", GetExecutingAssemblyVersion()); | ||
logEvent.Data.Add("exception", e); | ||
logEvent.Data.Add("context", context); | ||
_client.Log(logEvent); | ||
} | ||
|
||
public static void Log(string message, Exception e) | ||
{ | ||
if (_client == null) | ||
{ | ||
_client = GetClient(); | ||
} | ||
|
||
var logEvent = new LogglyEvent(); | ||
logEvent.Data.Add("version", GetExecutingAssemblyVersion()); | ||
logEvent.Data.Add("message", message); | ||
logEvent.Data.Add("exception", e); | ||
_client.Log(logEvent); | ||
} | ||
} | ||
|
||
public static void Log(object log) | ||
{ | ||
if (_client == null) | ||
{ | ||
_client = GetClient(); | ||
} | ||
|
||
var logEvent = new LogglyEvent(); | ||
logEvent.Data.Add("version", GetExecutingAssemblyVersion()); | ||
logEvent.Data.Add("message", log); | ||
_client.Log(logEvent); | ||
} | ||
|
||
private static Version GetExecutingAssemblyVersion() | ||
{ | ||
var ver = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location); | ||
|
||
// read what's defined in [assembly: AssemblyFileVersion("1.2.3.4")] | ||
return new Version(ver.ProductMajorPart, ver.ProductMinorPart, ver.ProductBuildPart, ver.ProductPrivatePart); | ||
} | ||
} | ||
} |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
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
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
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
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
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 |
---|---|---|
@@ -1,28 +1,30 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011"> | ||
<Metadata> | ||
<Identity Id="07fd7462-cd4b-433b-9ab5-8ad3ad87bc65" Version="3.8" Language="en-US" Publisher="Samir L. Boulema" /> | ||
<DisplayName>TSVN</DisplayName> | ||
<Description>Control TortoiseSVN from within Visual Studio</Description> | ||
<MoreInfo>https://visualstudiogallery.msdn.microsoft.com/64bfec35-0ac1-48bc-b9d0-921ecb803e53</MoreInfo> | ||
<License>Resources\License.txt</License> | ||
<GettingStartedGuide>https://github.com/sboulema/TSVN/blob/master/README.md</GettingStartedGuide> | ||
<ReleaseNotes>https://github.com/sboulema/TSVN/releases</ReleaseNotes> | ||
<Icon>Resources\Package.ico</Icon> | ||
<PreviewImage>Resources\tortoisesvn.png</PreviewImage> | ||
<Tags>SVN, Source control, Tortoise, repository</Tags> | ||
</Metadata> | ||
<Installation InstalledByMsi="false"> | ||
<InstallationTarget Id="Microsoft.VisualStudio.Pro" Version="[12.0,16.0)" /> | ||
</Installation> | ||
<Dependencies> | ||
<Dependency Id="Microsoft.Framework.NDP" DisplayName="Microsoft .NET Framework" d:Source="Manual" Version="[4.5,)" /> | ||
<Dependency Id="Microsoft.VisualStudio.MPF.12.0" DisplayName="Visual Studio MPF 12.0" d:Source="Installed" Version="12.0" /> | ||
</Dependencies> | ||
<Assets> | ||
<Asset Type="Microsoft.VisualStudio.VsPackage" d:Source="Project" d:ProjectName="%CurrentProject%" Path="|%CurrentProject%;PkgdefProjectOutputGroup|" /> | ||
</Assets> | ||
<Prerequisites> | ||
<Prerequisite Id="Microsoft.VisualStudio.Component.CoreEditor" Version="[15.0.25904.2,16.0)" DisplayName="Visual Studio core editor" /> | ||
</Prerequisites> | ||
<Metadata> | ||
<Identity Id="07fd7462-cd4b-433b-9ab5-8ad3ad87bc65" Version="3.8" Language="en-US" Publisher="Samir L. Boulema" /> | ||
<DisplayName>TSVN</DisplayName> | ||
<Description>Control TortoiseSVN from within Visual Studio</Description> | ||
<MoreInfo>https://visualstudiogallery.msdn.microsoft.com/64bfec35-0ac1-48bc-b9d0-921ecb803e53</MoreInfo> | ||
<License>Resources\License.txt</License> | ||
<GettingStartedGuide>https://github.com/sboulema/TSVN/blob/master/README.md</GettingStartedGuide> | ||
<ReleaseNotes>https://github.com/sboulema/TSVN/releases</ReleaseNotes> | ||
<Icon>Resources\Package.ico</Icon> | ||
<PreviewImage>Resources\tortoisesvn.png</PreviewImage> | ||
<Tags>SVN, Source control, Tortoise, repository</Tags> | ||
</Metadata> | ||
<Installation InstalledByMsi="false"> | ||
<InstallationTarget Id="Microsoft.VisualStudio.Pro" Version="[12.0,16.0)" /> | ||
<InstallationTarget Version="[12.0,16.0)" Id="Microsoft.VisualStudio.Community" /> | ||
<InstallationTarget Version="[12.0,16.0)" Id="Microsoft.VisualStudio.Enterprise" /> | ||
</Installation> | ||
<Dependencies> | ||
<Dependency Id="Microsoft.Framework.NDP" DisplayName="Microsoft .NET Framework" d:Source="Manual" Version="[4.5,)" /> | ||
<Dependency Id="Microsoft.VisualStudio.MPF.12.0" DisplayName="Visual Studio MPF 12.0" d:Source="Installed" Version="12.0" /> | ||
</Dependencies> | ||
<Assets> | ||
<Asset Type="Microsoft.VisualStudio.VsPackage" d:Source="Project" d:ProjectName="%CurrentProject%" Path="|%CurrentProject%;PkgdefProjectOutputGroup|" /> | ||
</Assets> | ||
<Prerequisites> | ||
<Prerequisite Id="Microsoft.VisualStudio.Component.CoreEditor" Version="[15.0.25904.2,16.0)" DisplayName="Visual Studio core editor" /> | ||
</Prerequisites> | ||
</PackageManifest> |
Oops, something went wrong.