Add daemon name to Logger entries
This commit is contained in:
parent
2e5958640a
commit
83ceb41138
|
@ -76,7 +76,9 @@ class Logger(object):
|
||||||
self.config = config
|
self.config = config
|
||||||
|
|
||||||
if self.config["file_logging"]:
|
if self.config["file_logging"]:
|
||||||
self.logfile = self.config["log_directory"] + "/pvc.log"
|
self.logfile = (
|
||||||
|
self.config["log_directory"] + "/" + self.config["daemon_name"] + ".log"
|
||||||
|
)
|
||||||
# We open the logfile for the duration of our session, but have a hup function
|
# We open the logfile for the duration of our session, but have a hup function
|
||||||
self.writer = open(self.logfile, "a", buffering=0)
|
self.writer = open(self.logfile, "a", buffering=0)
|
||||||
|
|
||||||
|
@ -139,20 +141,25 @@ class Logger(object):
|
||||||
if prefix != "":
|
if prefix != "":
|
||||||
prefix = prefix + " - "
|
prefix = prefix + " - "
|
||||||
|
|
||||||
# Assemble message string
|
|
||||||
message = colour + prompt + endc + date + prefix + message
|
|
||||||
|
|
||||||
# Log to stdout
|
# Log to stdout
|
||||||
if self.config["stdout_logging"]:
|
if self.config["stdout_logging"]:
|
||||||
print(message)
|
# Assemble output string
|
||||||
|
output = colour + prompt + endc + date + prefix + message
|
||||||
|
print(output)
|
||||||
|
|
||||||
# Log to file
|
# Log to file
|
||||||
if self.config["file_logging"]:
|
if self.config["file_logging"]:
|
||||||
self.writer.write(message + "\n")
|
# Assemble output string
|
||||||
|
output = colour + prompt + endc + date + prefix + message
|
||||||
|
self.writer.write(output + "\n")
|
||||||
|
|
||||||
# Log to Zookeeper
|
# Log to Zookeeper
|
||||||
if self.config["zookeeper_logging"]:
|
if self.config["zookeeper_logging"]:
|
||||||
self.zookeeper_queue.put(message)
|
# Set the daemon value (only used here as others do not overlap with different daemons)
|
||||||
|
daemon = f"{self.config['daemon_name']}: "
|
||||||
|
# Assemble output string
|
||||||
|
output = daemon + colour + prompt + endc + date + prefix + message
|
||||||
|
self.zookeeper_queue.put(output)
|
||||||
|
|
||||||
# Set last message variables
|
# Set last message variables
|
||||||
self.last_colour = colour
|
self.last_colour = colour
|
||||||
|
|
|
@ -63,7 +63,8 @@ def entrypoint():
|
||||||
|
|
||||||
# Get our configuration
|
# Get our configuration
|
||||||
config = pvcnoded.util.config.get_configuration()
|
config = pvcnoded.util.config.get_configuration()
|
||||||
config["pvcnoded_version"] = version
|
config["daemon_name"] = "pvcnoded"
|
||||||
|
config["daemon_version"] = version
|
||||||
|
|
||||||
# Create and validate our directories
|
# Create and validate our directories
|
||||||
pvcnoded.util.config.validate_directories(config)
|
pvcnoded.util.config.validate_directories(config)
|
||||||
|
|
|
@ -123,7 +123,7 @@ def setup_node(logger, config, zkhandler):
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
("node.data.pvc_version", config["node_hostname"]),
|
("node.data.pvc_version", config["node_hostname"]),
|
||||||
config["pvcnoded_version"],
|
config["daemon_version"],
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
("node.ipmi.hostname", config["node_hostname"]),
|
("node.ipmi.hostname", config["node_hostname"]),
|
||||||
|
@ -159,7 +159,7 @@ def setup_node(logger, config, zkhandler):
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
("node.data.pvc_version", config["node_hostname"]),
|
("node.data.pvc_version", config["node_hostname"]),
|
||||||
config["pvcnoded_version"],
|
config["daemon_version"],
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
("node.ipmi.hostname", config["node_hostname"]),
|
("node.ipmi.hostname", config["node_hostname"]),
|
||||||
|
|
Loading…
Reference in New Issue