-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unify logging #60
Unify logging #60
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the format you developed is good :) Just some minor corrections and nitpicks. So let's fix it and
src/Configuration.cpp
Outdated
@@ -44,9 +44,9 @@ void Configuration::set_all_available_sockets_if_empty() { | |||
} | |||
} | |||
if (socknames.empty()) { | |||
throw std::runtime_error("No sockets were configured and no sockets could be found."); | |||
throw std::runtime_error("Could not find and configure sockets."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this message is misleading now. It should state that no sockets were configured.
src/Configuration.cpp
Outdated
} | ||
WMLOG(DEBUG) << "No sockets were configured. Using all " << socknames.size() << " sockets available."; | ||
WMLOG(DEBUG) << "Could not configure sockets. Using all " << socknames.size() << " sockets available."; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not an error. There were no sockets specified and our auto-detection worked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does "Found" << socknames.size() << "available sockets".
sound better?
src/EventLoop.cpp
Outdated
<< event->station.vlan_id.value_or(0); | ||
WMLOG(INFO) << "Station " << event->station << " connected to AP for VXLAN " << event->station.vni() | ||
<< " at interface " << event->station.sockname; | ||
WMLOG(DEBUG) << "Calling handle_connect() for MAC:" << event->station |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are not calling the method it is already called. Maybe rather use entering?
src/EventLoop.cpp
Outdated
caller.deauth_station(event->station); | ||
} | ||
} | ||
|
||
void EventLoop::handle_disconnect(ipc::DisconnectEvent* event) { | ||
WMLOG(INFO) << "Station " << event->station << " disconnected from AP"; | ||
WMLOG(INFO) << "Disconnected station: " << event->station.mac.string(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sounds like we disconnected the station but rather the station decided to disconnect.
src/ipc/Socket.cpp
Outdated
@@ -74,29 +74,29 @@ ipc::Socket::Socket(const std::chrono::duration<int>& timeout, const std::string | |||
local.sun_path[sizeof(local.sun_path) - 1] = '\0'; | |||
if (bind(sock_fd, reinterpret_cast<struct sockaddr*>(&local), sizeof(local)) == -1) { | |||
close(sock_fd); | |||
throw std::runtime_error("could not bind to socket " + dest_path + ": " + std::strerror(errno)); | |||
throw std::runtime_error("Could not bind to socket " + dest_path + ": " + std::strerror(errno)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Colon missing.
src/ipc/Socket.cpp
Outdated
@@ -118,7 +118,7 @@ void ipc::Socket::send_command(const std::vector<std::string>& args) { | |||
|
|||
ssize_t err = send(sock_fd, command.c_str(), command.size(), 0); | |||
if (err < 0) { | |||
throw std::runtime_error(std::string("could not send_command to socket: ") + std::strerror(errno)); | |||
throw std::runtime_error(std::string("Could not send_command() to socket: ") + std::strerror(errno)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would write Could not send to socket:
src/nl/Socket.cpp
Outdated
@@ -122,7 +122,7 @@ void nl::Socket::delete_interface(const std::string &name) { | |||
if (err < 0) { | |||
throw std::runtime_error(std::string("Could not delete link: ") + nl_geterror(err)); | |||
} | |||
WMLOG(INFO) << "Deleted " << name; | |||
WMLOG(INFO) << "Deleted interface." << name; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Colon instead of dot
Please also rebase onto latest main so the pipeline is green. |
src/BridgePerVxlanRenderer.cpp
Outdated
|
||
if (not station.vlan_id.has_value()) { | ||
throw std::runtime_error("The station " + station.mac.string() + " has no vlan_id"); | ||
throw std::runtime_error("Station with MAC: " + station.mac.string() + " has no vlan_id."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my opinion, we should use key-value pairs to give additional information, and move them to the end.
For this log message, I propose "Station has no vlan_id mac=", similar for the others
518c2b9
to
59fb935
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our goal here is to make our logs searchable.
For example, if I wanted to find all events relating to a MAC address 00:00:00:00:00:01
, I would search for station=00:00:00:00:00:01
.
For that reason, I propose the following changes:
- We should use unified keys, for example
station
instead ofstation
ormac
- No whitespace between the
=
and the value - We should put the key-value pairs last and leave out prepositions like
with
before the pairs.
src/nl/Socket.cpp
Outdated
@@ -122,7 +122,7 @@ void nl::Socket::delete_interface(const std::string &name) { | |||
if (err < 0) { | |||
throw std::runtime_error(std::string("Could not delete link: ") + nl_geterror(err)); | |||
} | |||
WMLOG(INFO) << "Deleted " << name; | |||
WMLOG(INFO) << "Deleted interface:" << name; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use iface=
src/nl/Socket.cpp
Outdated
} | ||
WMLOG(INFO) << "Connected " << interface_name << " to " << bridge_name; | ||
WMLOG(INFO) << "Connected interface=" << interface_name << " to bridge= " << bridge_name; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should put the KV-pairs last
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would "Connected iface=" << interface_name << " bridge=" << bridge_name;
fit here?
Or do you suggest something else for this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me it is fine now. Thanks for all the work you put in @linaScience What do you think @rgwohlbold ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
No description provided.