~tyil/raku-log-colored

e14b96f2bc62a0380e97a123701b919f85f10e38 — Patrick Spek 5 months ago e7b9e0d
Update Log to latest version
2 files changed, 4 insertions(+), 117 deletions(-)

M META6.json
M lib/Log/Colored.rakumod
M META6.json => META6.json +2 -2
@@ 5,7 5,7 @@
    "Patrick Spek <p.spek@tyil.nl>"
  ],
  "depends": [
    "Log:auth<cpan:TYIL>",
    "Log:auth<cpan:TYIL>:ver<0.3.0>",
    "Terminal::ANSIColor"
  ],
  "description": "A Log implementation with colored output",


@@ 17,4 17,4 @@
  },
  "source-url": "https://home.tyil.nl/git/raku/Log::Colored/",
  "version": "0.1.1"
}
\ No newline at end of file
}

M lib/Log/Colored.rakumod => lib/Log/Colored.rakumod +2 -115
@@ 2,12 2,12 @@

use v6.d;

use Log;
use Log::Implementation;
use Log::Level;
use Terminal::ANSIColor;

#| An implementation of Log with colors.
unit class Log::Colored is Log;
unit class Log::Colored is Log::Implementation;

#| An array of hashes. Each has must have a handle key, with an IO::Handle to
#| print messages to. A level key with an integer to signify a Log::Level is


@@ 28,20 28,6 @@ multi method emergency (
	})
}

#| Send a formatted emergency message.
multi method emergency (
	#| A printf-style format string.
	Str:D $format,

	#| Arguments to substitute into the format string placeholders.
	*@args,
) {
	$!messages.emit({
		message => self!message($format.sprintf(|@args), 'bold underline red'),
		level => 0,
	})
}

#| Send an alert message.
multi method alert (
	#| The message to print.


@@ 53,20 39,6 @@ multi method alert (
	})
}

#| Send a formatted alert message.
multi method alert (
	#| A printf-style format string.
	Str:D $format,

	#| Arguments to substitute into the format string placeholders.
	*@args,
) {
	$!messages.emit({
		message => self!message($format.sprintf(|@args), 'bold red'),
		level => 1,
	})
}

#| Send a critical message.
multi method critical (
	#| The message to print.


@@ 78,20 50,6 @@ multi method critical (
	})
}

#| Send a formatted critical message.
multi method critical (
	#| A printf-style format string.
	Str:D $format,

	#| Arguments to substitute into the format string placeholders.
	*@args,
) {
	$!messages.emit({
		message => self!message($format.sprintf(|@args), 'red'),
		level => 2,
	})
}

#| Send an error message.
multi method error (
	#| The message to print.


@@ 103,20 61,6 @@ multi method error (
	})
}

#| Send a formatted error message.
multi method error (
	#| A printf-style format string.
	Str:D $format,

	#| Arguments to substitute into the format string placeholders.
	*@args,
) {
	$!messages.emit({
		message => self!message($format.sprintf(|@args), 'bold yellow'),
		level => 3,
	})
}

#| Send a warning message.
multi method warning (
	#| The message to print.


@@ 128,20 72,6 @@ multi method warning (
	})
}

#| Send a formatted warning message.
multi method warning (
	#| A printf-style format string.
	Str:D $format,

	#| Arguments to substitute into the format string placeholders.
	*@args,
) {
	$!messages.emit({
		message => self!message($format.sprintf(|@args), 'yellow'),
		level => 4,
	})
}

#| Send a notice message. This is the "normal" level to publish log entries on.
multi method notice (
	#| The message to print.


@@ 153,21 83,6 @@ multi method notice (
	})
}

#| Send a formatted notice message. This is the "normal" level to publish log
#| entries on.
multi method notice (
	#| A printf-style format string.
	Str:D $format,

	#| Arguments to substitute into the format string placeholders.
	*@args,
) {
	$!messages.emit({
		message => self!message($format.sprintf(|@args), 'default'),
		level => 5,
	})
}

#| Send an informational message.
multi method info (
	#| The message to print.


@@ 179,20 94,6 @@ multi method info (
	})
}

#| Send a formatted informational message.
multi method info (
	#| The printf-style format string.
	Str:D $format,

	#| Arguments to substitute into the format string placeholders.
	*@args,
) {
	$!messages.emit({
		message => self!message($format.sprintf(|@args), 'cyan'),
		level => 6,
	})
}

#| Send a debug message.
multi method debug (
	#| The message to print.


@@ 204,20 105,6 @@ multi method debug (
	})
}

#| Send a formatted debug message.
multi method debug (
	#| A printf-style format string.
	Str:D $format,

	#| Arguments to substitute into the format string placeholders.
	*@args,
) {
	$!messages.emit({
		message => self!message($format.sprintf(|@args), 'black'),
		level => 7,
	})
}

#| Add an output to the logger.
multi method add-output (
	#| The IO::Handle to write log messages to.