diff --git a/log/colors.v b/colors/colors.v similarity index 55% rename from log/colors.v rename to colors/colors.v index c8211c8685..279dcd189d 100644 --- a/log/colors.v +++ b/colors/colors.v @@ -2,108 +2,108 @@ // Use of this source code is governed by an MIT license // that can be found in the LICENSE file. -module log +module colors -pub fn format(msg, open, close string) string { +fn format(msg, open, close string) string { return '\x1b[' + open + 'm' + msg + '\x1b[' + close + 'm' } -pub fn bg_black(msg string) string { +fn bg_black(msg string) string { return format(msg, '40', '49') } -pub fn bg_blue(msg string) string { +fn bg_blue(msg string) string { return format(msg, '44', '49') } -pub fn bg_cyan(msg string) string { +fn bg_cyan(msg string) string { return format(msg, '46', '49') } -pub fn bg_green(msg string) string { +fn bg_green(msg string) string { return format(msg, '42', '49') } -pub fn bg_magenta(msg string) string { +fn bg_magenta(msg string) string { return format(msg, '45', '49') } -pub fn bg_red(msg string) string { +fn bg_red(msg string) string { return format(msg, '41', '49') } -pub fn bg_white(msg string) string { +fn bg_white(msg string) string { return format(msg, '47', '49') } -pub fn bg_yellow(msg string) string { +fn bg_yellow(msg string) string { return format(msg, '43', '49') } -pub fn black(msg string) string { +fn black(msg string) string { return format(msg, '30', '39') } -pub fn blue(msg string) string { +fn blue(msg string) string { return format(msg, '34', '39') } -pub fn bold(msg string) string { +fn bold(msg string) string { return format(msg, '1', '22') } -pub fn cyan(msg string) string { +fn cyan(msg string) string { return format(msg, '36', '39') } -pub fn dim(msg string) string { +fn dim(msg string) string { return format(msg, '2', '22') } -pub fn green(msg string) string { +fn green(msg string) string { return format(msg, '32', '39') } -pub fn gray(msg string) string { +fn gray(msg string) string { return format(msg, '90', '39') } -pub fn hidden(msg string) string { +fn hidden(msg string) string { return format(msg, '8', '28') } -pub fn italic(msg string) string { +fn italic(msg string) string { return format(msg, '3', '23') } -pub fn inverse(msg string) string { +fn inverse(msg string) string { return format(msg, '7', '27') } -pub fn magenta(msg string) string { +fn magenta(msg string) string { return format(msg, '35', '39') } -pub fn reset(msg string) string { +fn reset(msg string) string { return format(msg, '0', '0') } -pub fn red(msg string) string { +fn red(msg string) string { return format(msg, '31', '39') } -pub fn strikethrough(msg string) string { +fn strikethrough(msg string) string { return format(msg, '9', '29') } -pub fn underline(msg string) string { +fn underline(msg string) string { return format(msg, '4', '24') } -pub fn white(msg string) string { +fn white(msg string) string { return format(msg, '37', '39') } -pub fn yellow(msg string) string { +fn yellow(msg string) string { return format(msg, '33', '39') } diff --git a/examples/log b/examples/log deleted file mode 100755 index a6c8797959..0000000000 Binary files a/examples/log and /dev/null differ diff --git a/examples/log.v b/examples/log.v deleted file mode 100644 index b0ce07cbd5..0000000000 --- a/examples/log.v +++ /dev/null @@ -1,12 +0,0 @@ -import log - -fn main(){ - mut l := log.Log{level:log.INFO} - l.i('info') - l.w('warn') - l.e('error') - l.d('no debug') - l.set_level(log.DEBUG) - l.d('debug') - l.f('fatal') -} \ No newline at end of file diff --git a/log/log.v b/log/log.v deleted file mode 100644 index 7778732fc3..0000000000 --- a/log/log.v +++ /dev/null @@ -1,51 +0,0 @@ -module log - -const ( - FATAL = 1 - ERROR = 2 - WARN = 3 - INFO = 4 - DEBUG =5 -) - -struct Log{ -mut: - level int -} - - -pub fn (l mut Log) set_level(level int){ - l.level = level -} - -pub fn (l Log) f(s string){ - panic(s) -} - -pub fn (l Log) e(s string){ - if l.level >= ERROR{ - f := red('E') - println('[$f]$s') - } -} - -pub fn (l Log) w(s string){ - if l.level >= WARN{ - f := yellow('W') - println('[$f]$s') - } -} - -pub fn (l Log) i(s string){ - if l.level >= INFO{ - f := white('I') - println('[$f]$s') - } -} - -pub fn (l Log) d(s string){ - if l.level >= DEBUG{ - f := blue('D') - println('[$f]$s') - } -} \ No newline at end of file