Sunday, 28 November 2021

How do I prefix my log messages with the current date and time?

I'm using Python 3.9 and Django 3.2. I have logging configured in my settings.py file

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'handlers': {
        'console': {
            'class': 'logging.StreamHandler',
        },
    },
    'root': {
        'handlers': ['console'],
        'level': 'INFO',
    },
}

When I do logging in one of my classes, I do it like so

import logging
...
class TransactionService:
    def __init__(self):
        self._logger = logging.getLogger(__name__)


    def my_method(self, arg1, arg2):
            ...
        self._logger.info("Doing some logging here.")
      

  

How do I configure my logger such that when the message is printed out, it is prefixed by the current date and time?



from How do I prefix my log messages with the current date and time?

Apex chart Charts order in Mixed chart

I'm currently using the library ApexChart and more particulary Vue apex chart combined with nuxt.

I'm building a dashboard and I'm trying to build a mixed chart composed of :

  • An area chart
  • A Bar chart
  • A line chart

The three charts are displaying in the following order (from back to front) : Area - Bar - Line

I'd like to change the order to get the bar chart to the back but i don't see how to do it.

What i've tried

I've tried to change the order of the series to put the bar chart last

series() {
  return [
    {
      name: 'My Line chart',
      type: 'line',
      data: this.capacityCalls
    },
    {
      name: 'My Area Chart',
      type: 'area',
      data: this.callsRealProd
    },
    {
      name: 'My Bar Chart',
      type: 'bar',
      data: this.callsToMake
    },
  ]
},


from Apex chart Charts order in Mixed chart

Android Instrumented tests with KodeIn

We have an Android app that is using compose for the view layer and we are using Kodein for all of our dependency injections.

I have a BaseApplication class which is DIAware:

class BaseApplication : Application(), DIAware {
    override val di: DI = DI.lazy {
        import(modules) // modules defined in respective packages
    }
}

I also have a MainActivity and a nav graph to manage navigation between the various composables.

Problem: How can I properly override these modules in my instrumented tests for MainActivity?

@RunWith(AndroidJUnit4::class)
class MainActivityTest {
    @get:Rule
    val composeTestRule = createAndroidComposeRule<MainActivity>()

    val moduleOverrides = DI.Module(allowSilentOverride = true) {
        // add bindings for fakes w/ allowOverride = true
    }
    
    @Before
    fun setup() {
        val application =
            ApplicationProvider.getApplicationContext() as BaseApplication

        // how can I override the BaseApplication modules for my test?
    }

}

I cant seem to find any clear language on the matter and feel like I am missing something very obvious. Any help would be very much appreciated.



from Android Instrumented tests with KodeIn