26
            
            votes
        
        
            
            
        C++ logging library
                    Lots of good code comments already given. I'll focus on non-code aspects.
Take this from a DevOps engineer that regularly troubleshoots complex, unfamiliar systems from logs under time pressure.
You ...
                
            
       
        
            
                23
            
            votes
        
            
                
                Accepted
            
        
            
            
        Custom error-logging
                    Reusable methods
Notice that you have several methods that essentially do the same thing. Log and both writeCustomErrorLog ...
                
            
       
        
            
                20
            
            votes
        
        
            
        C++ logging library
                    I see a number of things that may help you improve your code.
Separate interface from implementation
The interface goes into a header file and the implementation (that is, everything that actually ...
                
            
       
        
            
                17
            
            votes
        
        
            
        Sensor logger for Raspberry Pi in a stratospheric probe
                    Do not call main recursively. You are setting yourself up for stack overflow. Consider instead
...
                
            
       
        
            
                17
            
            votes
        
            
                
                Accepted
            
        
            
            
        A simple error messaging and logging system via macro(s) in C++
                    You’ve already noted that this could be done better without macros, so I won’t belabour the point. I will note, though, that your goal—“to refresh [your] skills at writing good solid macros”—makes ...
                
            
       
        
            
                16
            
            votes
        
            
                
                Accepted
            
        
            
            
        Python script to analyse Apache log files
                    If code is repetitive, you probably need some functions and better data
organization. The current code is very repetitive: multiple versions of
nearly-but-not-quite identical code to handle the ...
                
            
       
        
            
                14
            
            votes
        
            
                
                Accepted
            
        
            
            
        Implementing a logging system in C++17
                    Is my code thread safe? If not, how do I make it thread safe?
No, of course it's not thread-safe. You don't do anything to make it thread-safe.
A more nuanced answer would be: It's thread-safe as long ...
                
            
       
        
            
                14
            
            votes
        
        
            
        C++ logging library
                    Making functions in header files static means that each translation unit gets its own separate definition. This usually isn't what we want. Standard practice is to declare the function in the header, ...
                
            
       
        
            
                11
            
            votes
        
            
                
                Accepted
            
        
            
            
        Sensor logger for Raspberry Pi in a stratospheric probe
                    Have you already executed the code to see how it performs and if the battery will last? There is that famous Donald Knuth quote saying premature optimization is the root of all evil (or at least most ...
                
            
       
        
            
                11
            
            votes
        
            
                
                Accepted
            
        
            
            
        Logger module in C
                    Redundant code
As the 4 functions are nearly identical, consider coding helper functions.
At a minimum, I recommend a ...
                
            
       
        
            
                11
            
            votes
        
        
        Implicitly logging the filepath of the callsite of the log-statement
                    Unless I am missing something, adapting the formatter slightly would produce the same result:
...
                
            
       
        
            
                10
            
            votes
        
            
                
                Accepted
            
        
            
            
        SQL trigger to log when employee records are updated
                    First some comments.
Usage of Deprecated Features
Currently your trigger does a SELECT that returns a resultset from a trigger. That was at one time supported but ...
                
            
       
        
            
                10
            
            votes
        
        
            
        C++ logging library
                    You have some good answers already. My criticism comes from one word. "printf".
The problem for fault-finding is not just knowing what each part has reported, but also knowing in what order they ...
                
            
       
        
            
                10
            
            votes
        
        
            
        C++ logging library
                    A few more suggestions in addition to the great existing answers:
Support logging stack traces - it's easy!
Standard C++ offers no facilities for obtaining stack traces, so traditionally - logging ...
                
            
       
        
            
                10
            
            votes
        
            
                
                Accepted
            
        
            
        Simple log rotation script
                    Return early, there's no need to touch files if the current file is <5mb.
DRY your code, move the "{}{}.{}".format into it's own function.
Don't use ...
                
            
       
        
            
                10
            
            votes
        
        
        C++ code for a simple single header logging library
                    General Observations:
It isn't clear why you are designing this log as a singleton. This allows only a single instance of the log in the program, what if I need multiple logs?
Should it be okay to run ...
                
            
       
        
            
                9
            
            votes
        
        
            
            
        C++ code for a simple single header logging library
                    That's a single header implementation in name only, but it isn't a header-only implementation. You need one (and exactly one) implementation file that uses some undocumented magic, namely
...
                
            
       
        
            
                9
            
            votes
        
            
                
                Accepted
            
        
            
        C++ code for a simple single header logging library
                    Use enum class
By default, C-like enum put their enumerators in the enclosing namespace. And that's not great at all.
From C++11 on, you can use enum class instead, ...
                
            
       
        
            
                8
            
            votes
        
            
                
                Accepted
            
        
            
        Error-Handling Class and Logging for VBA
                    Amount of boilerplate code
As it is, there are lot of boilerplate that we must provide to set up everything. At a minimum, we need the following code:
...
                
            
       
        
            
                8
            
            votes
        
        
        Sensor logger for Raspberry Pi in a stratospheric probe
                    Opening and closing files takes resources:
with open('babar.txt', 'a') as f: f.write('a'*10000)
takes 300 micro-seconds while:
...
                
            
       
        
            
                8
            
            votes
        
            
                
                Accepted
            
        
            
        Operation logger
                    One drawback I can think of this way of logging is that (correct me if I'm wrong) it is lazy. That's to say, until the root Op object is ...
                
            
       
        
            
                8
            
            votes
        
            
                
                Accepted
            
        
            
            
        Minimal Python logging
                    Setting up logging
You might be interested in logging.basicConfig, which can setup everything you setup there as well. It's not sufficient if you want for example ...
                
            
       
        
            
                8
            
            votes
        
        
            
            
        Custom Logger class
                    Docstrings should be on the inside of a function or class, not on the outside - before the def or class.
Your logger doesn't ...
                
            
       
        
            
                7
            
            votes
        
        
            
        SQL trigger to log when employee records are updated
                    You are basically reformatting one group of fields into another. I'm not sure if that's a good idea - you might want to just make a straight-up copy of the fields, since that improves your "audit" ...
                
            
       
        
            
                7
            
            votes
        
        
            
            
        Advanced Python logging system
                    PEP-8 Conventions
Top-level functions should be separated (preceded and followed) by two blank lines:
...
                
            
       
        
            
                7
            
            votes
        
        
            
            
        Custom error-logging
                    Coding style
Variable names
Avoid variable names like sw or st. In your code they still make sense because they're the ...
                
            
       
        
            
                7
            
            votes
        
            
                
                Accepted
            
        
            
            
        Logger that writes to text file with std::vformat
                    The class seems pointless, since it can't even be instantiated.  Why not a free function (in a suitable namespace, perhaps)?
The function itself opens and closes ...
                
            
       
        
            
                6
            
            votes
        
        
            
        Custom error-logging
                    A few other things:
1) Your implementation is not thread safe. It is not clear how you are going to use it in multi-threaded environment.
2) Reopening file stream for every log message is ...
                
            
       
        
            
                6
            
            votes
        
            
                
                Accepted
            
        
            
            
        Reading SQL query from a resource, with error logging
                    The most unforgivable aspect of this code is that it rethrows a degraded exception.  The original type of the exception (likely an IOException) and the stack trace ...
                
            
       
        
            
                6
            
            votes
        
        
            
            
        Process queued data in the background
                    Alternatives
There are plenty of robust options for message queueing in C# that handle multithreading  gracefully as well as scaling to truly massive sizes.
The microsoft solution is MSMQ.
There ...
                
            
       
        Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
logging × 335python × 76
c# × 55
c++ × 50
java × 47
error-handling × 29
performance × 28
python-3.x × 26
beginner × 21
parsing × 21
multithreading × 19
javascript × 17
c × 16
file × 14
object-oriented × 12
go × 11
c++11 × 10
thread-safety × 9
library × 9
php × 8
ruby × 8
.net × 8
c++17 × 8
design-patterns × 7
datetime × 7
 
         
         
         
         
         
         
         
         
         
         
         
         
         
         
        