Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7550241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T10:09:45+00:00 2026-05-30T10:09:45+00:00

I created an overriding formatter which masks some strings like this: class MaskFormatter(logging.Formatter): def

  • 0

I created an overriding formatter which masks some strings like this:

class MaskFormatter(logging.Formatter):

    def __init__(self, fmt, mask):
        logging.Formatter.__init__(self, fmt, mask)
        self.mask = mask

    def format(self, record):
        result = logging.Formatter.format(self, record)
        if result is not None and result.find(self.mask) != -1:
            result = result.replace(self.mask, '*' * len(self.mask))
        return result    

I use it like this:

formatter = MaskFormatter('%(asctime)s %(levelname)s' + 
    ' %(module)s %(lineno)d %(message)s', mask='abcde')
hdlr.setLevel(logging.DEBUG)
logger.setLevel(logging.DEBUG)
hdlr.setFormatter(formatter)

however in my log lines i noticed that the datetime is now also masked!! althought i asked it to mask only “abcde” can someone help please?

all log lines has prefix ***** instead of real datetime:

***** DEBUG mail
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T10:09:46+00:00Added an answer on May 30, 2026 at 10:09 am

    Looking at the documentation for logging formatters, it says that Formatter takes two optional arguments. The first is the message format, the second is the datetime format. It looks like you are sending the mask in as the datetime format. Try dropping the mask argument from the logging.Formatter.init call.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a delegated Array class like this: class LeadPartArray < DelegateClass(Array) def
I created an adapter public class MyArrayAdapter extends ArrayAdapter<Watch> overriding public MyArrayAdapter(Context context, List<Watch>
I'm trying to serlialize a class I created, it's not working and for some
I have a stateless, abstract base class from which various concrete classes inherit. Some
I'm trying to do some custom authorization so I created a controller overriding the
Having some trouble overriding ActionBarSherlock styles, hopefully someone can help. I have created a
I created a custom ToggleButton class, ToggleButtonEx, that extends ToggleButton. ToggleButtonEx contains some dependency
I created a program using dev-cpp and wxwidgets which solves a puzzle. The user
I created a Rails application normally. Then created the scaffold for an event class.
I created an object that extends android.view.View , overriding draw() and have it displaying

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.