Comments (5)
fak u jj
from openage.
On colors in logs:
Terminal programs that can output color should have a --color
command-line option. --color
is short for --color=always
(some programs get this wrong). --color=never
and --color=auto
also exist; the latter is the default if the option is not found on the command line at all.
If --color=auto
is chosen, check isatty(3)
on the file descriptor you are writing to - either stdout
(STDOUT_FILENO=1
) or stderr
(STDERR_FILENO=2
). Output written to files other than stdout and stderr should ignore the command-line option and output no color. (Possibly there might be a separate configuration option color_in_log_files
but this probably wouldn't be available as a command-line option. There's also an exception if you explicitly open a new tty.)
As a GUI program that only writes to stdout
/stderr
as a secondary sink, it feels funny for openage to accept --color
, but the same principles should apply.
from openage.
As for the API itself, I think it is a fatal mistake to think in terms of logging strings. Instead, log structures. In particular, this is useful for what I do a lot, which is parse files. My logging structure is like:
enum class LogLevel { WARNING, ERROR };
struct LogMessage {
io::LineSpan span;
std::string message;
};
struct LogEntry {
LogLevel level;
LogMessage main_message;
std::string option; // think [-Wfoo] from gcc; don't store the "-W" because "level" controls how it prints
std::vector<LogMessage> notes;
};
Additionally, since I'm making a server, it's my goal to switch all my logging to syslog, since otherwise I have to reinvent log rotation and everything manually.
from openage.
@o11c Don't worry, I have a pretty sophisticated design (I just was too lazy to actually implement it up until now).
from openage.
@mic-e de_aztec crickets
from openage.
Related Issues (20)
- CLI parameter for engine start mode
- "error: βDictβ is not a member of βnyanβ" during build HOT 7
- Can't build with clang, error: "jthread is supported now, remove custom definition" HOT 4
- Asset conversion issue, AttributeError: 'NoneType' object has no attribute 'readable' HOT 6
- Adding PR/ISSUE Templates for this repo HOT 7
- Asset path type is incorrectly used HOT 5
- error: Couldn't find qml root folder HOT 15
- Test fail when building with GCC 13.2.1 HOT 10
- Error launching game, uncaught exception(s) HOT 25
- openage game: error: the following arguments are required: --modpacks HOT 4
- Running Error on Mac osx 13.4(Macbook M1 Pro ARM architecture) HOT 1
- FATAL: terminate has been called uncaught exception std::exception of type std::__1::system_error: thread::join failed: Invalid argument HOT 2
- Multiple cmake issues when trying to build HOT 4
- Submission to Steam HOT 2
- OpenGL error when launching on Wayland HOT 11
- CMake can't find toml11 on Linux Mint 21.2 HOT 4
- Errors after the new PR merged HOT 3
- Link on website https://openage.sft.mx/ to windows packages is a broken link HOT 2
- Windows Build: Python Command Requiring --modpacks Argument HOT 3
- Asset conversion stalls on media conversion HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from openage.