From b457854f239b5c9a5b88113c4925bfa9dfb1eddf Mon Sep 17 00:00:00 2001 From: Karchnu Date: Fri, 28 Aug 2020 01:33:33 +0200 Subject: [PATCH] Initial commit. --- shard.yml | 2 ++ src/baguette-crystal-base.cr | 43 ++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 shard.yml create mode 100644 src/baguette-crystal-base.cr diff --git a/shard.yml b/shard.yml new file mode 100644 index 0000000..6e35467 --- /dev/null +++ b/shard.yml @@ -0,0 +1,2 @@ +name: baguette-crystal-base +version: 0.1.0 diff --git a/src/baguette-crystal-base.cr b/src/baguette-crystal-base.cr new file mode 100644 index 0000000..55df3a5 --- /dev/null +++ b/src/baguette-crystal-base.cr @@ -0,0 +1,43 @@ +require "colorize" + +class Baguette::Context + class_property verbosity = 1 +end + +class Baguette::Log + # FIXME: Use log files. + # FIXME: def log(), that puts stuff as-is in the logs. + + def self.debug(text) + return unless Baguette::Context.verbosity > 2 + STDERR.puts ":: #{text}".colorize(:cyan) + STDERR.flush + end + def self.info(text) + return unless Baguette::Context.verbosity > 1 + STDOUT + .<<(":: ".colorize(:blue)) + .<<(text.colorize(:white)) + .<<("\n") + STDOUT.flush + end + def self.title(text) + return unless Baguette::Context.verbosity > 1 + STDOUT + .<<("|> ".colorize(:blue).bright) + .<<(text.colorize(:white).bright) + .<<("\n") + STDOUT.flush + end + def self.warning(text) + return unless Baguette::Context.verbosity > 0 + STDERR.puts ":: #{text}".colorize(:yellow) + STDERR.flush + end + def self.error(text) + return unless Baguette::Context.verbosity > 0 + STDERR.puts "!! #{text}".colorize(:red) + STDERR.flush + end +end +