Add logging.colour settings option

This commit is contained in:
Starbeamrainbowlabs 2019-07-16 18:01:17 +01:00
parent 680b5cb16e
commit 2a9de80848
4 changed files with 15 additions and 3 deletions

View file

@ -12,13 +12,13 @@
* - Initial public release * - Initial public release
*/ */
class Ansi { class Ansi {
constructor() { constructor(enabled = true) {
/** /**
* Whether we should *actually* emit ANSI escape codes or not. * Whether we should *actually* emit ANSI escape codes or not.
* Useful when we want to output to a log file, for example * Useful when we want to output to a log file, for example
* @type {Boolean} * @type {Boolean}
*/ */
this.enabled = true; this.enabled = enabled;
this.escape_codes(); this.escape_codes();
} }

View file

@ -34,6 +34,10 @@ export default async function setup() {
DataProcessor: a.asClass(DataProcessor) DataProcessor: a.asClass(DataProcessor)
}); });
// Enable / disable colourising the output
c.cradle.ansi.enabled = settings.logging.colour;
c.cradle.ansi.escape_codes();
let repo_filenames = await fs.readdir(path.join(root_dir, "./Repos.SQLite")); let repo_filenames = await fs.readdir(path.join(root_dir, "./Repos.SQLite"));
for(let repo_filename of repo_filenames) { for(let repo_filename of repo_filenames) {

View file

@ -54,9 +54,13 @@ devices = [
[logging] [logging]
# The format the date displayed when logging things should take. # The format the date displayed when logging things should take.
# Allowed values: relative (e.g like when a Linux machine boots), absolute (e.g. like Nginx server logs) # Allowed values: relative (e.g like when a Linux machine boots), absolute (e.g. like Nginx server logs), none (omits it entirely))
date_display_mode = "relative" date_display_mode = "relative"
# Whether we should be verbose and log a bunch of stuff to the console. # Whether we should be verbose and log a bunch of stuff to the console.
# Disabled by default, but useful for debugging. # Disabled by default, but useful for debugging.
verbose = false verbose = false
# Whether we should output ANSI escape sequences to colourise the output or not.
# Defaults to true, but you should turn it off if you're using syslog.
colour = true

View file

@ -17,5 +17,9 @@ ExecStart=/home/sbrl/Msc-Summer-Project/build server-ttn
Restart=always Restart=always
# Other Restart options: or always, on-abort, etc # Other Restart options: or always, on-abort, etc
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=ttn-listener
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target