python exception message capturing

import ftplib import urllib2 import os import logging logger = logging.getLogger(‘ftpuploader’) hdlr = logging.FileHandler(‘ftplog.log’) formatter = logging.Formatter(‘%(asctime)s %(levelname)s %(message)s’) hdlr.setFormatter(formatter) logger.addHandler(hdlr) logger.setLevel(logging.INFO) FTPADDR = “some ftp address” def upload_to_ftp(con, filepath): try: f = open(filepath,’rb’) # file to send con.storbinary(‘STOR ‘+ filepath, f) # Send the file f.close() # Close file and FTP logger.info(‘File successfully uploaded … Read more

Hide strange unwanted Xcode logs

When using the Xcode 8+ and creating a new blank project, the following logs appear when running the application: 2016-06-13 16:33:34.406093 TestiOS10[8209:100611] bundleid: com.appc.TestiOS10, enable_level: 0, persist_level: 0, propagate_with_activity: 0 2016-06-13 16:33:34.406323 TestiOS10[8209:100607] Created DB, header sequence number = 248 2016-06-13 16:33:34.409564 TestiOS10[8209:100611] subsystem: com.apple.UIKit, category: HIDEvents, enable_level: 0, persist_level: 0, default_ttl: 0, info_ttl: 0, … Read more

Control verbosity level of WP DEBUG?

I’ve been at a loss so far and so I thought I’d pose the question: Is there a way to modify the verbosity level of the WP debug.log via wp-config.php or elsewhere? Just an fyi, here is what I have in my wp-config.php to enable logging: /////////////////////////////////////////////////// // DEBUG // Enable WP_DEBUG mode define(‘WP_DEBUG’, true); … Read more

How to have ‘git log’ show filenames like ‘svn log -v’

SVN’s log has a “-v” mode that outputs filenames of files changed in each commit, like so: jes5199$ svn log -v ———————————————————————— r1 | jes5199 | 2007-01-03 14:39:41 -0800 (Wed, 03 Jan 2007) | 1 line Changed paths: A /AUTHORS A /COPYING A /ChangeLog A /EVOLUTION A /INSTALL A /MacOSX Is there a quick way … Read more

String formatting: % vs. .format vs. f-string literal

Python 2.6 introduced the str.format() method with a slightly different syntax from the existing % operator. Which is better and for what situations? Python 3.6 has now introduced another string formatting format of string literals (aka “f” strings) via the syntax f”my string”. Is this formatting option better than the others? The following uses each … Read more

What is the significance of log4j.rootLogger property in log4j.properties file? What happens if I don’t use this property?

Samudra Gupta explains in his book1: The Logger object is the main object that an application developer uses to log any message. The Logger objects acting within a particular instance of an application follow a parent-child hierarchy. If you have the following configuration: log4j.rootLogger=WARN, stdout log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.SimpleLayout log4j.logger.com.me.proj2=INFO This is how the logger hierarchy could end up looking:2 Samudra Gupta … Read more