mirror of
https://github.com/jbranchaud/til
synced 2026-03-03 22:48:45 +00:00
Compare commits
2 Commits
f48adc0f05
...
dd6350aa41
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dd6350aa41 | ||
|
|
bdd3adf577 |
@@ -10,7 +10,7 @@ working across different projects via [VisualMode](https://www.visualmode.dev/).
|
||||
|
||||
For a steady stream of TILs, [sign up for my newsletter](https://visualmode.kit.com/newsletter).
|
||||
|
||||
_1730 TILs and counting..._
|
||||
_1732 TILs and counting..._
|
||||
|
||||
See some of the other learning resources I work on:
|
||||
|
||||
@@ -1073,6 +1073,7 @@ If you've learned something here, support my efforts writing daily TILs by
|
||||
- [Check If ActiveRecord Update Fails](rails/check-if-activerecord-update-fails.md)
|
||||
- [Check If Any Records Have A Null Value](rails/check-if-any-records-have-a-null-value.md)
|
||||
- [Check Specific Attributes On ActiveRecord Array](rails/check-specific-attributes-on-activerecord-array.md)
|
||||
- [Check The Current Named Log Level](rails/check-the-current-named-log-level.md)
|
||||
- [Clean Up Memory Hungry Rails Console Processes](rails/clean-up-memory-hungry-rails-console-processes.md)
|
||||
- [Code Statistics For An Application](rails/code-statistics-for-an-application.md)
|
||||
- [Columns With Default Values Are Nil On Create](rails/columns-with-default-values-are-nil-on-create.md)
|
||||
@@ -1675,6 +1676,7 @@ If you've learned something here, support my efforts writing daily TILs by
|
||||
- [Fix Previous Command With fc](unix/fix-previous-command-with-fc.md)
|
||||
- [Fix Shim Path After asdf Upgrade](unix/fix-shim-path-after-asdf-upgrade.md)
|
||||
- [Fix Unlinked Node Binaries With asdf](unix/fix-unlinked-node-binaries-with-asdf.md)
|
||||
- [Format And Display Small Amounts Of Columnar Data](unix/format-and-display-small-amounts-of-columnar-data.md)
|
||||
- [Forward Multiple Ports Over SSH](unix/forward-multiple-ports-over-ssh.md)
|
||||
- [Generate A SAML Key And Certificate Pair](unix/generate-a-saml-key-and-certificate-pair.md)
|
||||
- [Generate A Sequence Of Numbered Items](unix/generate-a-sequence-of-numbered-items.md)
|
||||
|
||||
46
rails/check-the-current-named-log-level.md
Normal file
46
rails/check-the-current-named-log-level.md
Normal file
@@ -0,0 +1,46 @@
|
||||
# Check The Current Named Log Level
|
||||
|
||||
I'm connected to a `rails console` session for an active Rails app. I want to
|
||||
check the current log level.
|
||||
|
||||
```ruby
|
||||
> Rails.logger.level
|
||||
=> 1
|
||||
```
|
||||
|
||||
The `1` doesn't mean much to me at a glance. I can translate that to the
|
||||
severity level using the `Logger::SEV_LABLE` constant.
|
||||
|
||||
```ruby
|
||||
[44] pry(main)> Logger::SEV_LABEL[Rails.logger.level]
|
||||
=> "INFO"
|
||||
```
|
||||
|
||||
Ah yes, `INFO`, that makes sense as the default.
|
||||
|
||||
I can see all the severity levels by inspecting the constant itself.
|
||||
|
||||
```ruby
|
||||
[45] pry(main)> Logger::SEV_LABEL
|
||||
=> ["DEBUG", "INFO", "WARN", "ERROR", "FATAL", "ANY"]
|
||||
```
|
||||
|
||||
As I convenience, I can set the label using the index, the string, or even a
|
||||
symbol.
|
||||
|
||||
```ruby
|
||||
> Rails.logger.level
|
||||
=> 1
|
||||
> Rails.logger.level = "WARN"
|
||||
=> "WARN"
|
||||
> Rails.logger.level
|
||||
=> 2
|
||||
> Rails.logger.level = :debug
|
||||
=> :debug
|
||||
> Rails.logger.level
|
||||
=> 0
|
||||
```
|
||||
|
||||
See the [Debugging Rails Applications
|
||||
guide](https://guides.rubyonrails.org/debugging_rails_applications.html#log-levels)
|
||||
for more details.
|
||||
44
unix/format-and-display-small-amounts-of-columnar-data.md
Normal file
44
unix/format-and-display-small-amounts-of-columnar-data.md
Normal file
@@ -0,0 +1,44 @@
|
||||
# Format And Display Small Amounts Of Columnar Data
|
||||
|
||||
In [_List Processes Running Across All (tmux)
|
||||
Sessions](tmux/list-processes-running-across-all-sessions.md), I showed an
|
||||
example of piping some data from `tmux` to the `column -t` command to nicely format
|
||||
and display the columnar data as a table. By default is uses spaces as the
|
||||
delimiter.
|
||||
|
||||
```bash
|
||||
❯ tmux list-panes -a -F "#{session_name}:#{window_index}.#{pane_index} #{pane_pid} #{pane_current_command}" \
|
||||
| column -t
|
||||
|
||||
PLP:1.1 62364 zsh
|
||||
TIL:1.1 62345 nvim
|
||||
TIL:1.2 65838 task
|
||||
TIL:2.1 11428 tmux
|
||||
client-app:1.1 62373 ssh
|
||||
client-app:1.2 10796 zsh
|
||||
client-app:1.3 63081 zsh
|
||||
client-app:2.1 61115 overmind
|
||||
client-app:3.1 82608 zsh
|
||||
visualmode-dev:1.1 52237 zsh
|
||||
```
|
||||
|
||||
This can be useful for formatting data from all kinds of commands and tools.
|
||||
Sometimes the columns of data are separated by something other than spaces. For
|
||||
instance, here is some git branch information (for my [dotfiles
|
||||
repo](https://github.com/jbranchaud/dotfiles)) separated by the `|` character.
|
||||
To format that with `column`, I need to also include the `-s '|'` flag to
|
||||
override the delimiter.
|
||||
|
||||
```bash
|
||||
❯ git for-each-ref --format='%(refname:short)|%(authordate:short)|%(authorname)' refs/heads/ \
|
||||
| column -t -s '|'
|
||||
|
||||
claude/sync-dotfiles-011CUP87cRV6c51eEi3Chg99 2025-10-22 jbranchaud
|
||||
jb/add-rhubarb-for-fugitive-github-browse 2025-11-02 jbranchaud
|
||||
jb/fix-hardcoded-paths 2025-11-02 jbranchaud
|
||||
jb/set-nvim-to-default-manpager 2025-10-19 jbranchaud
|
||||
main 2026-01-10 jbranchaud
|
||||
master 2025-10-30 Dorian Karter
|
||||
my-dotfiles 2025-11-01 jbranchaud
|
||||
upstream-master 2026-01-01 Dorian Karter
|
||||
```
|
||||
Reference in New Issue
Block a user