Skip to content

Commit

Permalink
Renormalize line endings
Browse files Browse the repository at this point in the history
  • Loading branch information
jskeet committed Sep 10, 2020
1 parent 6fddee6 commit cbaa00a
Show file tree
Hide file tree
Showing 7 changed files with 2,110 additions and 2,110 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

240 changes: 120 additions & 120 deletions apis/Google.Cloud.Logging.NLog/Google.Cloud.Logging.NLog.sln

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,16 @@ public partial class GoogleStackdriverTarget
/// </summary>
public int TaskPendingLimit { get; set; } = 5;

/// <summary>
/// Configures "service" for the "serviceContext" when <see cref="SendJsonPayload" /> = true
/// <summary>
/// Configures "service" for the "serviceContext" when <see cref="SendJsonPayload" /> = true
/// </summary>
public Layout ServiceContextName { get; set; } = "${appdomain:cached=true:format=\\{1\\}}";

/// <summary>
/// Configures "version" for the "serviceContext" when <see cref="SendJsonPayload" /> = true
/// </summary>
public Layout ServiceContextVersion { get; set; } = "${assembly-version:cached=true:type=File}";

public Layout ServiceContextName { get; set; } = "${appdomain:cached=true:format=\\{1\\}}";

/// <summary>
/// Configures "version" for the "serviceContext" when <see cref="SendJsonPayload" /> = true
/// </summary>
public Layout ServiceContextVersion { get; set; } = "${assembly-version:cached=true:type=File}";

/// <summary>
/// The resource type of log entries.
/// Default value depends on the detected platform. See the remarks section for details.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,56 +1,56 @@
// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using Newtonsoft.Json;

namespace Google.Cloud.Logging.NLog
{
/// <summary>
/// JSON converter that just calls ToString on the target value (when non-null).
/// This is configured as the converter for types that will otherwise spew a lot of irrelevant JSON
/// into logs.
/// </summary>
internal sealed class ToStringJsonConverter : JsonConverter
{
private readonly System.Type _type;

/// <inheritdoc />
public override bool CanRead => false;

public ToStringJsonConverter(System.Type type) =>
_type = type;

/// <inheritdoc />
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
if (value is null)
{
writer.WriteNull();
}
else
{
writer.WriteValue(value.ToString());
}
}

/// <inheritdoc />
public override object ReadJson(JsonReader reader, System.Type objectType, object existingValue, JsonSerializer serializer) =>
throw new NotSupportedException("Only serialization is supported");

/// <inheritdoc />
public override bool CanConvert(System.Type objectType) =>
_type.IsAssignableFrom(objectType);
}
}
// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using Newtonsoft.Json;

namespace Google.Cloud.Logging.NLog
{
/// <summary>
/// JSON converter that just calls ToString on the target value (when non-null).
/// This is configured as the converter for types that will otherwise spew a lot of irrelevant JSON
/// into logs.
/// </summary>
internal sealed class ToStringJsonConverter : JsonConverter
{
private readonly System.Type _type;

/// <inheritdoc />
public override bool CanRead => false;

public ToStringJsonConverter(System.Type type) =>
_type = type;

/// <inheritdoc />
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
if (value is null)
{
writer.WriteNull();
}
else
{
writer.WriteValue(value.ToString());
}
}

/// <inheritdoc />
public override object ReadJson(JsonReader reader, System.Type objectType, object existingValue, JsonSerializer serializer) =>
throw new NotSupportedException("Only serialization is supported");

/// <inheritdoc />
public override bool CanConvert(System.Type objectType) =>
_type.IsAssignableFrom(objectType);
}
}
110 changes: 55 additions & 55 deletions apis/Google.Cloud.Logging.NLog/Google.Cloud.Logging.NLog/readme.md
Original file line number Diff line number Diff line change
@@ -1,55 +1,55 @@
# Google Cloud Logging NLog target

`Google.Cloud.Logging.NLog` is a .NET client library to integrate [Google Stackdriver Logging](https://cloud.google.com/logging/)
with [NLog](https://github.com/NLog/NLog).

## Installation

Install the `Google.Cloud.Logging.NLog` package from NuGet. Add it to
your project in the normal way (for example by right-clicking on the
project in Visual Studio and choosing "Manage NuGet Packages...").
Please ensure you enable pre-release packages (for example, in the
Visual Studio NuGet user interface, check the "Include prerelease"
box).

## Getting started

This library uses the [Google-Cloud-Dotnet](https://googleapis.github.io/google-cloud-dotnet/) libraries which authenticate
using the default service account on the machine. This is automatic on GCE VMs or you can use the [gcloud](https://cloud.google.com/sdk/) SDK
to authenticate yourself. The service account must have the [Logs Writer](https://cloud.google.com/logging/docs/access-control) permission to send logs.

When using default options, logs will appear under these filter settings in the GCP Console.

## Target Options

* **ProjectId** - Google Cloud project ID where logs will be sent to. Can be omitted if executing on on [Google App Engine (GAE)](https://cloud.google.com/appengine/) or [Google Compute Engine (GCE)](https://cloud.google.com/compute/)
* **ResourceType** - Resource type for logs (Default = "global"). Must be one of the supported types listed in the [cloud logging documentation](https://cloud.google.com/logging/docs/api/v2/resource-list).
* **LogId** - Name of log under the resource type (Default = "Default")
* **DisableResourceTypeDetection** - Defaults to false. Setting this to true disables automatic resourceType setting based on platform detection.
* **ResourceLabel** - If resourceType has been manually set, then resourceLabel is used to specify extra labels as shown in the [Monitoring Resource Types](https://cloud.google.com/logging/docs/api/v2/resource-list) list.
* **ContextProperty** - Allows custom labels to be added to the log entries as extra metadata.
* **CredentialFile** - Credentials using a JSON file, instead of using the default credentials (GOOGLE_APPLICATION_CREDENTIALS)
* **CredentialJson** - Credentials using raw JSON input, instead of using the default credentials (GOOGLE_APPLICATION_CREDENTIALS)
* **IncludeCallSite** - Include LogEntrySourceLocation extracted from NLog callsite (Only include function name)
* **IncludeCallSiteStackTrace** - Include LogEntrySourceLocation extracted from NLog callsite (Also include filename and linenumber)
* **IncludeEventProperties** - Includes structured logging properties from NLog LogEventInfo.Properties
* **IncludeMdlc** - Include async thread context properties from NLog MappedDiagnosticsLogicalContext
* **SendJsonPayload** - Instead of sending properties as custom labels, then they are sent as Json-Properties in JsonPayload (without TextPayload)
* **ServiceContextName** - Configures the "service" in "serviceContext" when SendJsonPayload = true (Default = AppDomain FriendlyName)
* **ServiceContextVersion** - Configures the "version" in "serviceContext" when SendJsonPayload = true (Default = Entry Assembly FileVersion)

```xml
<extensions>
<add assembly="Google.Cloud.Logging.NLog" />
</extensions>
<targets>
<target type="GoogleStackdriver"
name="String"
projectId="your project ID"
logId="your log ID"
layout="Layout">
<resourcelabel name="String" layout="Layout" /><!-- repeated -->
<contextproperty name="String" layout="Layout" /><!-- repeated -->
</target>
</targets>
```
# Google Cloud Logging NLog target

`Google.Cloud.Logging.NLog` is a .NET client library to integrate [Google Stackdriver Logging](https://cloud.google.com/logging/)
with [NLog](https://github.com/NLog/NLog).

## Installation

Install the `Google.Cloud.Logging.NLog` package from NuGet. Add it to
your project in the normal way (for example by right-clicking on the
project in Visual Studio and choosing "Manage NuGet Packages...").
Please ensure you enable pre-release packages (for example, in the
Visual Studio NuGet user interface, check the "Include prerelease"
box).

## Getting started

This library uses the [Google-Cloud-Dotnet](https://googleapis.github.io/google-cloud-dotnet/) libraries which authenticate
using the default service account on the machine. This is automatic on GCE VMs or you can use the [gcloud](https://cloud.google.com/sdk/) SDK
to authenticate yourself. The service account must have the [Logs Writer](https://cloud.google.com/logging/docs/access-control) permission to send logs.

When using default options, logs will appear under these filter settings in the GCP Console.

## Target Options

* **ProjectId** - Google Cloud project ID where logs will be sent to. Can be omitted if executing on on [Google App Engine (GAE)](https://cloud.google.com/appengine/) or [Google Compute Engine (GCE)](https://cloud.google.com/compute/)
* **ResourceType** - Resource type for logs (Default = "global"). Must be one of the supported types listed in the [cloud logging documentation](https://cloud.google.com/logging/docs/api/v2/resource-list).
* **LogId** - Name of log under the resource type (Default = "Default")
* **DisableResourceTypeDetection** - Defaults to false. Setting this to true disables automatic resourceType setting based on platform detection.
* **ResourceLabel** - If resourceType has been manually set, then resourceLabel is used to specify extra labels as shown in the [Monitoring Resource Types](https://cloud.google.com/logging/docs/api/v2/resource-list) list.
* **ContextProperty** - Allows custom labels to be added to the log entries as extra metadata.
* **CredentialFile** - Credentials using a JSON file, instead of using the default credentials (GOOGLE_APPLICATION_CREDENTIALS)
* **CredentialJson** - Credentials using raw JSON input, instead of using the default credentials (GOOGLE_APPLICATION_CREDENTIALS)
* **IncludeCallSite** - Include LogEntrySourceLocation extracted from NLog callsite (Only include function name)
* **IncludeCallSiteStackTrace** - Include LogEntrySourceLocation extracted from NLog callsite (Also include filename and linenumber)
* **IncludeEventProperties** - Includes structured logging properties from NLog LogEventInfo.Properties
* **IncludeMdlc** - Include async thread context properties from NLog MappedDiagnosticsLogicalContext
* **SendJsonPayload** - Instead of sending properties as custom labels, then they are sent as Json-Properties in JsonPayload (without TextPayload)
* **ServiceContextName** - Configures the "service" in "serviceContext" when SendJsonPayload = true (Default = AppDomain FriendlyName)
* **ServiceContextVersion** - Configures the "version" in "serviceContext" when SendJsonPayload = true (Default = Entry Assembly FileVersion)

```xml
<extensions>
<add assembly="Google.Cloud.Logging.NLog" />
</extensions>
<targets>
<target type="GoogleStackdriver"
name="String"
projectId="your project ID"
logId="your log ID"
layout="Layout">
<resourcelabel name="String" layout="Layout" /><!-- repeated -->
<contextproperty name="String" layout="Layout" /><!-- repeated -->
</target>
</targets>
```

0 comments on commit cbaa00a

Please sign in to comment.