preaction / Beam-Wire

A simple configuration and dependency injection container
Other
11 stars 10 forks source link

[question] constructor with unusual args #76

Closed XSven closed 1 year ago

XSven commented 2 years ago

The Log::Log4perl::Appender constructor has a single positional parameter (the dispatcher class name) and a hash (not hashref) of named parameters that refers to the constructor attributes of the dispatcher class. How can I configure such an appender object in Beam::Wire?

This works

FILE-appender:
  class: Log::Log4perl::Appender
  args:
    - Log::Log4perl::Appender::File
    - name
    - FILE
    - filename
    - file.log

but it is awful.

preaction commented 1 year ago

That'd be the canonical way to do it, unfortunately. A better solution might be a Beam::Service::Log4perl::Appender wrapper module that translates whatever config you want into the appropriate arguments.