-
Notifications
You must be signed in to change notification settings - Fork 862
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
[core] New formatting implementation using SFMT for the logging system #2955
base: master
Are you sure you want to change the base?
Conversation
…pdated sfmt implementation
…adowed local variables
srtcore/sfmt.h
Outdated
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.
Please use a unique name to avoid conflicts with the fmt
library.
For example, srt_format.h.
The same for namespaces used. The main one must be srt
. Then maybe again not fmt
but something more unique, unless fmt
library can be used instead if enabled in CMake.
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.
It doesn't actually, this is distributed in my fork of the {fmt} library and there are no conflicting names there (and its license is PD, so it can be freely copied). Although I understand that to really avoid any potential conflicts in the future it should use different naming. I would keep the "sfmt" name at least as a part of the filename. As for the namespace, I think it may simply go whole into srt
namespace, I think there are no name conflicts against it.
srtcore/sfmt.h
Outdated
@@ -0,0 +1,1047 @@ | |||
// Formatting library for C++ - C++03 compat version of on-demand tagged format API. | |||
// | |||
// Copyright (c) 2024 - present, Mikołaj Małecki |
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.
Copyright - Haivision. Authors: Mikołaj Małecki
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.
Well, I'm not sure about that. Although it should be mentioned that it is copied from an open-source library distributed with PD license.
const internal::form_memory_buffer<2> seol ("\n"); | ||
|
||
// Another manipulator. You can add yourself others the same way. | ||
const struct os_flush_manip {} sflush; |
Check notice
Code scanning / CodeQL
Unused static variable Note
void open(const std::string& name, const std::string& mode = "") | ||
{ | ||
if (mode == "") | ||
in = std::fopen(name.c_str(), "w"); |
Check failure
Code scanning / CodeQL
File created without restricting permissions High
This reimplements the logging system by replacing the iostream-based system with a custom class that does formatting through snprintf. The use of
std::ostringstream
has been replaced withfmt::obufstream
, which should do the same string building.Other changes, beside replacement of state tags for formatting with the use of
sfmt
, are explicit type conversions limited to those that can be handled by snprintf.Note that this implementation has been created FOR RESEARCH ONLY.