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 4599120
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T23:29:44+00:00 2026-05-21T23:29:44+00:00

Does someone know any way to organize the logging statements more conveniently? I guess

  • 0

Does someone know any way to organize the logging statements more conveniently?

I guess there is no such way, but, well, here is a small example:

        // Take the longest path in the graph and convert it into the
        // image series, note that we project every element from the
        // sequence into the image path so that 'new Series(...)' constructor
        // could be used.
        var paths = EnumerateSimpleAndLoopedPaths().ToList();

        logger.Log(Something1);

        if (paths.Any())
        {
            // Take the longest possible path.
            var selectedPath = paths.OrderBy(x => x.Count()).Last();

            logger.Log(Something2);

            var imagesForSelectedPath = selectedPath.SelectMany(...

Obviously those logger.Log or Log or whatever statements are just like rubbish for the main code part, maybe there is a smart way to take them somewhere?

I know there are some nice packages, like PostSharp, which allows logging to be done before and after – but what if functions have to log some intermediate result of their work?

Or is this just a decomposition problem and I should make everything more decomposed so that I could mark all those loggable entries as [Loggable]?

Any suggestions would be appreciated. What do you do with logging in your code?

  • 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-21T23:29:44+00:00Added an answer on May 21, 2026 at 11:29 pm

    How about divided the inner logic of method to additional private methods to do the intermediate work,

    or, if you don’t want to end up with too many methods on class that can only be used in one place, …

    define an inner class to do the work (which automatically can access private members of parent class, if you pass reference to parent to inner class’s constructor).
    The inner class can have many private methods that can be accessed only by methods on the inner class. So define one public/internal method on inner class, to be called by method on outer class.

    With both approaches, you can decorate new methods with attributes for AOP (e.g. PostSharp).

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

Sidebar

Related Questions

In jQuery ajax function there is xhr option. Does someone know more details, usability
Does anyone know if there is any way to exclude certain words from being
Does someone know a simple way to set the default zoom and latitude/longitude with
I need to know if there is any way of writing additional code to
Does someone know of any uses of m4 besides autoconf (preferably in a c
Does someone know a way on how to check, in Java, if a string
In Short: Does any know a way from the base controller to get a
I would like to know if there is any way to capture a to
Does someone know how to find the longest common subsequence of a set of
Does someone know why i never get the first value of my array? it

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.