Browse Source

dev + dev_as_prod

main
pvincent 2 months ago
parent
commit
4d682e1814
  1. 7
      bin/dev
  2. 19
      bin/dev_as_prod
  3. 3
      bin/journal_reverse
  4. 10
      bin/journal_tail
  5. 10
      bin/sprod
  6. 10
      lib/semantic/abstract_formatter.rb
  7. 10
      lib/semantic/basic_formatter.rb
  8. 8
      lib/semantic/fancy_formatter.rb

7
bin/dev

@ -10,10 +10,11 @@ fi
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
if [[ -d public/assets ]]; then if [[ -d public/assets ]]; then
echo
echo "You have probably precompiled assets for production purpose!" echo "You have probably precompiled assets for production purpose!"
echo "Would you like to remove these assets before running in DEV:"
echo "- Press Enter to continue"
echo "- Press Ctrl+C to cancel"
echo
echo "Would you like to remove these assets before running in DEV?"
echo "-- Press Enter to confirm / Ctrl+C to cancel"
read read
rm -rf public/assets rm -rf public/assets
fi fi

19
bin/dev_as_prod

@ -0,0 +1,19 @@
#!/usr/bin/env bash
export RAILS_ENV=production
export SECRET_KEY_BASE=42
export SEMANTIC_LOGGER_APP=egr
if [[ -d public/assets ]]; then
echo "ASSETS are already precompiled: MODIFIED_TIME"
else
rails assets:precompile
fi
rails server
# TO REMOVE PROD assets:
# rm -rf public/assets
# journalctl --all -o cat --full -t egr
# journalctl --all -o short -full --no-hostname -t egr -f

3
bin/journal_reverse

@ -0,0 +1,3 @@
#!/usr/bin/env bash
SEMANTIC_LOGGER_APP=egr journalctl --all -o short --no-hostname -t $SEMANTIC_LOGGER_APP --reverse

10
bin/journal_tail

@ -0,0 +1,10 @@
#!/usr/bin/env bash
export RAILS_ENV=production
export SECRET_KEY_BASE=42
export SEMANTIC_LOGGER_APP=egr
# TODO: current user belong to `adm` group
journalctl --all -o short --no-hostname -t $SEMANTIC_LOGGER_APP -f
# journalctl --all -o cat -t $SEMANTIC_LOGGER_APP -f

10
bin/sprod

@ -1,10 +0,0 @@
#!/bin/bash
RAILS_ENV=production SECRET_KEY_BASE='toto est fluo' rails assets:precompile
# TO REMOVE PROD assets:
# rm -rf public/assets
SEMANTIC_LOGGER_APP=egr RAILS_ENV=production SECRET_KEY_BASE='toto est fluo' rails server
# journalctl --all -o cat --full -t egr
journalctl --all -o short --no-hostname -t egr -f

10
lib/semantic/abstract_formatter.rb

@ -6,14 +6,8 @@ module Semantic
CENTER_SIZE = 20 CENTER_SIZE = 20
TAG_FIXED_LENGTH = Rails.application.config.x.action_controller.main_session_tag_fixed_length || 10 TAG_FIXED_LENGTH = Rails.application.config.x.action_controller.main_session_tag_fixed_length || 10
def initialize(time_format: nil)
super(color_map: ColorMap.new(
debug: CLEAR + TEXT_GRAY_400,
info: CLEAR + TEXT_GRAY_100,
warn: CLEAR + BG_YELLOW + TEXT_BLACK,
error: CLEAR + DARK_BG_RED + TEXT_WHITE,
fatal: CLEAR + BG_MAGENTA + BOLD + TEXT_WHITE
))
def initialize(color_map:, time_format: nil)
super(color_map:)
@time_format = time_format @time_format = time_format
end end

10
lib/semantic/basic_formatter.rb

@ -1,14 +1,18 @@
module Semantic module Semantic
# My Custom colorized formatter # My Custom colorized formatter
class BasicFormatter < AbstractFormatter class BasicFormatter < AbstractFormatter
ANSI_REVERSED_WARNING = "\e[0;30;43m".freeze
ANSI_REVERSED_ERROR = "\e[1;30;41m".freeze
MAX_LENGTH_LINE = 255 MAX_LENGTH_LINE = 255
PRIME = '▍'.freeze PRIME = '▍'.freeze
CONTINATION = '▕'.freeze CONTINATION = '▕'.freeze
def initialize(time_format: nil) def initialize(time_format: nil)
super
super(time_format:, color_map: ColorMap.new(
debug: TEXT_GRAY_400,
info: TEXT_GREEN,
warn: TEXT_YELLOW,
error: LIGHT_TEXT_RED,
fatal: TEXT_MAGENTA
))
end end
def call(log, logger) def call(log, logger)

8
lib/semantic/fancy_formatter.rb

@ -13,7 +13,13 @@ module Semantic
TOTAL_RENDERED_VIEW_DURATION = RENDERED_VIEW_DURATION * 5 TOTAL_RENDERED_VIEW_DURATION = RENDERED_VIEW_DURATION * 5
def initialize(time_format: nil) def initialize(time_format: nil)
super
super(time_format:, color_map: ColorMap.new(
debug: CLEAR + TEXT_GRAY_400,
info: CLEAR + TEXT_GRAY_100,
warn: CLEAR + BG_YELLOW + TEXT_BLACK,
error: CLEAR + DARK_BG_RED + TEXT_WHITE,
fatal: CLEAR + BG_MAGENTA + BOLD + TEXT_WHITE
))
@memory = nil @memory = nil
end end

Loading…
Cancel
Save