Hot answers tagged

46 votes
Accepted

Someone thinks poorly of my server log parser

Firstly, Python has a style guide and (unless you're given a different guide, in which case please provide a link to it) you should follow it. Your code generally follows it, but note that the ...
user avatar
  • 13.8k
30 votes
Accepted

Logging without Code Bloat

This kind of trace logging could conceivably be solved with an Aspect. Aspect oriented programming allows you to add boilerplate-style code to your program without actually writing the boilerplate ...
user avatar
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 ...
user avatar
  • 16.4k
23 votes
Accepted

Custom error-logging

Reusable methods Notice that you have several methods that essentially do the same thing. Log and both writeCustomErrorLog ...
user avatar
  • 5,397
20 votes

Logging without Code Bloat

Looking at your code, I believe that your problem is not only that the logging lines are ugly but they are a risk in costing you more than helping you: Like comments, log line maintenance is often ...
user avatar
  • 6,557
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 ...
user avatar
  • 64.1k
18 votes

Pretty way of keeping sensitive info out of a logged command string in Ruby?

I see two more security issues with this code. Executing a string rather than an array of command and parameters When building a command line programmatically, it is dangerous to build it as a ...
user avatar
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 ...
user avatar
  • 53k
16 votes
Accepted

Windows keylogger in C

You register keydown events for Control and Alt keys, but don't note when they are released. Therefore, you would not be able to distinguish between r and Controlr by reading the transcript. Those ...
user avatar
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 ...
user avatar
  • 9,510
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, ...
user avatar
14 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 ...
user avatar
  • 8,116
13 votes

Parsing log files of HearthStone: The log reading API

The Design A LogReader reads a log, filters the unwanted stuff and converts it into LogEntries. According to your design. That'...
user avatar
  • 22.2k
12 votes

Windows keylogger in C

You have some global variables in main.c: bool invisible = true; char fileName[MAX_PATH]; They should be placed in the closest local scope possible and passed to ...
user avatar
  • 34.7k
12 votes
Accepted

Custom Logging Class: Efficiency

Efficiency the biggest improvement will be to not open the config file each time you log something, but only once when instantiating the logger. you could also open the log file only once, but it ...
user avatar
  • 24.9k
12 votes

Recurrence, recursive function

There's no way to tell this in a friendly manner: your indentation is abysmal. Let's fix that up first. Note that there's plenty left to improve, like giving your operators some space, but I'll leave ...
user avatar
  • 12.6k
11 votes

Someone thinks poorly of my server log parser

+ in regex means Once or more. I think in your case you are mistaking it for a concatenation operator. I think you could ...
user avatar
  • 673
11 votes

Parsing log files of HearthStone: The log reading API

I'll just go through this from top to bottom ...
user avatar
  • 25k
11 votes
Accepted

Automatic flowchart generator

You're a Python native, aren't you? I can tell from the """ multiline strings and the four-space indents and really unidiomatic whitespacing and ...
user avatar
  • 5,463
11 votes
Accepted

Try-except decorator for classmethods

1. Design The decorator mechanism seems hard to use, unreliable, and counter-productive. It's hard to use because you have to remember to add it to every method that might raise an exception. It's ...
user avatar
  • 49.1k
11 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 ...
user avatar
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 ...
user avatar
  • 226
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 ...
user avatar
10 votes
Accepted

A Simple, One-Page PHP Admin Login (with prepared SQL statements)

Security I'm not all that comfortable with echoing unsanitized user input: echo '<form action=' . $_SERVER['REQUEST_URI'] . ' method = "post">';. I did not ...
user avatar
  • 24.9k
10 votes
Accepted

Filtering log files from a server

Raising useful errors If you have something like this: raise You're doing something wrong. Just calling raise with no ...
user avatar
10 votes
Accepted

Scraping after login using Scrapy

I'll start off by saying this is actually really good. There are a few minor PEP8 errors: In after_login you call Request. the ...
user avatar
  • 41.6k
10 votes
Accepted

Simple log writer class

The code is pretty good, and quite readable. Here are some of the things I noticed: Header guards Your Logger.h needs header guards: ...
user avatar
  • 3,225
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 ...
user avatar
  • 2,009
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 ...
user avatar
  • 359

Only top scored, non community-wiki answers of a minimum length are eligible