Coder Social home page Coder Social logo

New logger subsystem about openage HOT 5 CLOSED

sfttech avatar sfttech commented on April 28, 2024
New logger subsystem

from openage.

Comments (5)

mic-e avatar mic-e commented on April 28, 2024

fak u jj

from openage.

o11c avatar o11c commented on April 28, 2024

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.

o11c avatar o11c commented on April 28, 2024

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.

mic-e avatar mic-e commented on April 28, 2024

@o11c Don't worry, I have a pretty sophisticated design (I just was too lazy to actually implement it up until now).

from openage.

franciscod avatar franciscod commented on April 28, 2024

@mic-e de_aztec crickets

from openage.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.