forked from aspnet/AspNetWebStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRazorEditorTrace.cs
More file actions
54 lines (50 loc) · 1.66 KB
/
Copy pathRazorEditorTrace.cs
File metadata and controls
54 lines (50 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Web.Razor.Resources;
using System.Web.Razor.Text;
namespace System.Web.Razor.Editor
{
internal static class RazorEditorTrace
{
private static bool? _enabled;
private static bool IsEnabled()
{
if (_enabled == null)
{
bool enabled;
if (Boolean.TryParse(Environment.GetEnvironmentVariable("RAZOR_EDITOR_TRACE"), out enabled))
{
Trace.WriteLine(String.Format(
CultureInfo.CurrentCulture,
RazorResources.Trace_Startup,
enabled ? RazorResources.Trace_Enabled : RazorResources.Trace_Disabled));
_enabled = enabled;
}
else
{
_enabled = false;
}
}
return _enabled.Value;
}
[Conditional("EDITOR_TRACING")]
public static void TraceLine(string format, params object[] args)
{
if (IsEnabled())
{
Trace.WriteLine(String.Format(
CultureInfo.CurrentCulture,
RazorResources.Trace_Format,
String.Format(CultureInfo.CurrentCulture, format, args)));
}
}
}
}