Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: Build Basic Logging Library #1

Open
2 tasks
nelsonic opened this issue Dec 3, 2022 · 3 comments
Open
2 tasks

Chore: Build Basic Logging Library #1

nelsonic opened this issue Dec 3, 2022 · 3 comments
Assignees
Labels
documentation Improvements or additions to documentation enhancement New feature or enhancement of existing functionality good first issue Good for newcomers help wanted If you can help make progress with this issue, please comment! priority-2 Second highest priority, should be worked on as soon as the Priority-1 issues are finished T2h Time Estimate 2 Hours tech-debt A feature/requirement implemented in a sub-optimal way & must be re-written technical A technical issue that requires understanding of the code, infrastructure or dependencies

Comments

@nelsonic
Copy link
Member

nelsonic commented Dec 3, 2022

https://hex.pm/packages/logs
image

image

Todo

# Research

Briefly looked at https://github.com/sile/logi
image
But the docs are in JP 🇯🇵 : https://github.com/sile/logi/blob/master/README.ja.md
image
And it does waaaay too much stuff. The author clearly knows what they are doing: https://github.com/sile
image
But right now I just want the simplest possible interface we can use and get back to our work!

@nelsonic nelsonic added documentation Improvements or additions to documentation enhancement New feature or enhancement of existing functionality good first issue Good for newcomers help wanted If you can help make progress with this issue, please comment! labels Dec 3, 2022
@nelsonic nelsonic changed the title Chore: Build Logging Library Chore: Build Basic Logging Library Dec 3, 2022
nelsonic added a commit that referenced this issue Dec 4, 2022
nelsonic added a commit that referenced this issue Dec 4, 2022
@nelsonic
Copy link
Member Author

nelsonic commented Dec 4, 2022

@nelsonic nelsonic added technical A technical issue that requires understanding of the code, infrastructure or dependencies T2h Time Estimate 2 Hours tech-debt A feature/requirement implemented in a sub-optimal way & must be re-written priority-2 Second highest priority, should be worked on as soon as the Priority-1 issues are finished labels Dec 7, 2022
@nelsonic nelsonic self-assigned this Dec 7, 2022
@panoramix360
Copy link

hey! I was looking through the dwyl projects and I found logs reading through things on the imgup.

Did you guys already create a POC or something for this project?

I was curious and thinking of starting something or helping define it.

Maybe we need to define some things like:

  • The different types of logs that we want to support, like error, debug, and info logs for example
  • If we are going to have different severity of logs.
  • If we are going to store logs in a database or just send them to other platforms like AWS, Azure, etc. Or even write to a file. Or just the console. It's nice to add support for different outputs when the time comes.
  • The Python logging lib is a really nice starting point to get some ideas, together with your recommendation.

Well, let's open the chat so we can discuss some ideas if you guys are willing to do it.

I'd be excited to work on something if it reaches that point.

@ndrean
Copy link

ndrean commented Aug 24, 2023

@nelsonic Seems a good candidate https://github.com/onkel-dirtus/logger_file_backend/tree/master. You can separate :info, :debug, :warning easily.

Screenshot 2023-08-24 at 17 56 28

I made a quick test by redirecting Logger.debug and Logger.info into their own files. Output example:

18:10:25.825 [debug] Replied in 42µs
18:10:25.825 [debug] HANDLE PARAMS in LiveNavWeb.HomeLive
  Parameters: %{}
18:10:25.825 [debug] Replied in 13µs
18:10:29.955 [debug] HANDLE EVENT "update_count" in LiveNavWeb.HomeLive
  Parameters: %{"value" => ""}
18:10:29.956 [debug] Elixir.LiveNavWeb.HomeLive: count: 1
18:10:29.956 [debug] Replied in 1ms
18:10:30.185 [debug] HANDLE EVENT "update_count" in LiveNavWeb.HomeLive
  Parameters: %{"value" => ""}
18:10:30.185 [debug] Elixir.LiveNavWeb.HomeLive: count: 2
18:10:30.185 [debug] Replied in 507µs
18:18:05.134 [info] Running LiveNavWeb.Endpoint with cowboy 2.10.0 at 127.0.0.1:4000 (http)
18:18:05.135 [info] Access LiveNavWeb.Endpoint at http://localhost:4000
18:18:09.231 [info] GET /
18:18:09.272 [info] Sent 200 in 40ms
18:18:09.339 [info] CONNECTED TO Phoenix.LiveView.Socket in 11µs
  Transport: :websocket
  Serializer: Phoenix.Socket.V2.JSONSerializer
  Parameters: %{"_csrf_token" => "XAVjB2w0ExklQmwDKmRBOCAACjQHKB9-hFS_XUfPN2Xln-sZZVceDRm4", "_live_referer" => "undefined", "_mounts" => "0", "_track_static" => %{"0" => "http://localhost:4000/assets/app.css", "1" => "http://localhost:4000/assets/app.js"}, "vsn" => "2.0.0"}
18:18:09.346 [info] Elixir.LiveNavWeb.HomeLive: mounted

I believe this can to S3.

This config is simple.

# Configures Elixir's Logger
config :logger, :console,
  format: "$time $metadata[$level] $message\n",
  metadata: [:request_id]

config :logger,
  backends: [{LoggerFileBackend, :error_log}, {LoggerFileBackend, :info}]

config :logger, :error_log,
  path: "./error.log",
  level: :debug

config :logger, :info,
  path: "./info.log",
  level:  : info 
def application do
    [
      mod: {LiveNav.Application, []},
      extra_applications: [:logger, :runtime_tools, :logger_file_backend]
    ]
  end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or enhancement of existing functionality good first issue Good for newcomers help wanted If you can help make progress with this issue, please comment! priority-2 Second highest priority, should be worked on as soon as the Priority-1 issues are finished T2h Time Estimate 2 Hours tech-debt A feature/requirement implemented in a sub-optimal way & must be re-written technical A technical issue that requires understanding of the code, infrastructure or dependencies
Projects
Status: No status
Development

No branches or pull requests

3 participants