Skip to content

Commit

Permalink
Upgrade paket tool and all deps
Browse files Browse the repository at this point in the history
  • Loading branch information
haf committed Aug 29, 2019
1 parent 7036413 commit b6feca4
Show file tree
Hide file tree
Showing 27 changed files with 1,550 additions and 1,629 deletions.
42 changes: 0 additions & 42 deletions .paket/paket.bootstrapper.proj

This file was deleted.

8 changes: 0 additions & 8 deletions .paket/paket.bootstrapper.props

This file was deleted.

94 changes: 94 additions & 0 deletions examples/Logary.AspNetCore.API/Controllers/TodoController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Logary.AspNetCore.API.Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;

namespace Logary.AspNetCore.API.Controllers
{
[Route("api/todo")]
[ApiController]
public class TodoController : ControllerBase
{
readonly TodoContext _context;

public TodoController(TodoContext context)
{
_context = context;

if (_context.TodoItems.Any()) return;

// Create a new TodoItem if collection is empty,
// which means you can't delete all TodoItems.
_context.TodoItems.Add(new TodoItem { Name = "Use Logary for logging" });
_context.TodoItems.Add(new TodoItem { Name = "Use Logary for Prometheus scraping" });
_context.TodoItems.Add(new TodoItem { Name = "Use Logary for Jaeger tracing" });
_context.TodoItems.Add(new TodoItem { Name = "Use Logary for rate limiting with Logary.Trace.Samplers.RateLimiter" });
_context.SaveChanges();
}

// GET: api/todo
[HttpGet]
public async Task<ActionResult<IEnumerable<TodoItem>>> GetTodoItems()
{
return await _context.TodoItems.ToListAsync();
}

// GET: api/todo/5
[HttpGet("{id}")]
public async Task<ActionResult<TodoItem>> GetTodoItem(long id)
{
var todoItem = await _context.TodoItems.FindAsync(id);

if (todoItem == null)
{
return NotFound();
}

return todoItem;
}

// POST: api/todo
[HttpPost]
public async Task<ActionResult<TodoItem>> PostTodoItem(TodoItem item)
{
_context.TodoItems.Add(item);
await _context.SaveChangesAsync();

return CreatedAtAction(nameof(GetTodoItem), new { id = item.Id }, item);
}

// PUT: api/todo/5
[HttpPut("{id}")]
public async Task<IActionResult> PutTodoItem(long id, TodoItem item)
{
if (id != item.Id)
{
return BadRequest();
}

_context.Entry(item).State = EntityState.Modified;
await _context.SaveChangesAsync();

return NoContent();
}

// DELETE: api/todo/5
[HttpDelete("{id}")]
public async Task<IActionResult> DeleteTodoItem(long id)
{
var todoItem = await _context.TodoItems.FindAsync(id);

if (todoItem == null)
{
return NotFound();
}

_context.TodoItems.Remove(todoItem);
await _context.SaveChangesAsync();

return NoContent();
}
}
}
15 changes: 15 additions & 0 deletions examples/Logary.AspNetCore.API/Logary.AspNetCore.API.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\adapters\Logary.Adapters.AspNetCore\Logary.Adapters.AspNetCore.fsproj"/>
<ProjectReference Include="..\..\src\Logary.CSharp\Logary.CSharp.csproj"/>
<ProjectReference Include="..\..\src\Logary\Logary.fsproj"/>
<ProjectReference Include="..\..\src\targets\Logary.Targets.Jaeger\Logary.Targets.Jaeger.fsproj"/>
</ItemGroup>

<Import Project="..\..\.paket\Paket.Restore.targets"/>
</Project>
14 changes: 14 additions & 0 deletions examples/Logary.AspNetCore.API/Models/TodoContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Microsoft.EntityFrameworkCore;

namespace Logary.AspNetCore.API.Models
{
public class TodoContext : DbContext
{
public TodoContext(DbContextOptions<TodoContext> options)
: base(options)
{
}

public DbSet<TodoItem> TodoItems { get; set; }
}
}
9 changes: 9 additions & 0 deletions examples/Logary.AspNetCore.API/Models/TodoItem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Logary.AspNetCore.API.Models
{
public class TodoItem
{
public long Id { get; set; }
public string Name { get; set; }
public bool IsComplete { get; set; }
}
}
40 changes: 40 additions & 0 deletions examples/Logary.AspNetCore.API/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using System.Threading.Tasks;
using Logary.Configuration;
using Logary.Targets;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Logging;
using ILogger = Logary.Configuration.ILogger;

namespace Logary.AspNetCore.API
{
public class Program
{
public static async Task Main(string[] args)
{
var logary = await LogaryFactory.New("Logary.AspNetCore.API", config =>
config
.InternalLogger(ILogger.NewLiterateConsole(LogLevel.Verbose))
.LoggerMinLevel(".*", LogLevel.Verbose)
.Target<LiterateConsole.Builder>(
"literate",
lit => lit.Target.WithExtendedTokeniser().Done())
.Target<Logary.Targets.Jaeger.Builder>(
"jaeger",
x =>
x.Target
.WithJaegerAgent("localhost", 30831)
.Done())
);

CreateWebHostBuilder(args, logary).Build().Run();
}

static IWebHostBuilder CreateWebHostBuilder(string[] args, LogManager logary)
{
return WebHost.CreateDefaultBuilder(args)
.ConfigureLogging(logging => logging.AddLogary(logary))
.UseStartup<Startup>();
}
}
}
30 changes: 30 additions & 0 deletions examples/Logary.AspNetCore.API/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:5779",
"sslPort": 44307
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "api/values",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Logary.AspNetCore.API": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "api/todo",
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
41 changes: 41 additions & 0 deletions examples/Logary.AspNetCore.API/Startup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using Logary.AspNetCore.API.Models;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

namespace Logary.AspNetCore.API
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}

public IConfiguration Configuration { get; }

// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<TodoContext>(opt =>
opt.UseInMemoryDatabase("TodoList"));
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
app.UseDeveloperExceptionPage();
else
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();

//app.UseHttpsRedirection();
app.UseMvc();
}
}
}
9 changes: 9 additions & 0 deletions examples/Logary.AspNetCore.API/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
}
}
8 changes: 8 additions & 0 deletions examples/Logary.AspNetCore.API/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Warning"
}
},
"AllowedHosts": "*"
}
3 changes: 3 additions & 0 deletions examples/Logary.AspNetCore.API/paket.references
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
group AspNetCoreExample
Microsoft.AspNetCore.App
Microsoft.AspNetCore
1 change: 0 additions & 1 deletion examples/Logary.Suave/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ let main _ =
LiterateConsole.create LiterateConsole.empty "console"
Jaeger.create { Jaeger.empty with jaegerPort = 30831us } "jaeger"
]
|> Config.processing (Events.events |> Events.sink ["console"; "jaeger"])
|> Config.build
|> run

Expand Down
2 changes: 1 addition & 1 deletion examples/aspnetcore/AspNetCore.CSharp/paket.references
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
group AspNetCoreAdapterExample
group AspNetCoreExample
Microsoft.AspNetCore.App
Loading

0 comments on commit b6feca4

Please sign in to comment.