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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:48:21+00:00 2026-05-26T17:48:21+00:00

I need a logging library for my multi-threaded Tcl aplication. Can I use standard

  • 0

I need a logging library for my multi-threaded Tcl aplication. Can I use standard logger package? If I can, what restrictions are applied in multi-threading environment?

I’d like to share logging services among the threads, if possible.

Thanks

  • 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-26T17:48:22+00:00Added an answer on May 26, 2026 at 5:48 pm

    Tcl threads do not share data (unless you explicitly use certain facilities from the Thread package) and instead are communicating via message passing. So it seems like the way to go would be to setup a dedicated “logger” thread and just queue logging messages into it from the worker threads.

    Otherwise the point of contention will probably be somewhere in the OS resource used by the logger to actually write data.

    Update Okay, here’s a working sketch of what I actually proposed to implement:

    package require Tcl 8.5
    package require Thread
    
    proc make_worker_thread {logger_id body} {
      set newbody [list set ::logger $logger_id]
      append newbody \n {
        proc ::log {severity msg} {
          global logger
          thread::send $logger [list ::log $severity $msg]
        }
      } \n $body
      thread::create $newbody
    }
    
    set logger [thread::create {
      package require logger
    
      proc log {severity msg} {
        puts "hey, that's it: ($severity) $msg"
      }
    
      puts "logger thread created: [thread::id]"
    
      thread::wait
    }]
    
    for {set i 0} {$i < 3} {incr i} {
      make_worker_thread $logger {
        proc post_msg {} {
          log notice "A message from [thread::id]"
            after 1000 ::post_msg
        }
    
        puts "worker thread created: [thread::id]"
    
        after 1000 ::post_msg
    
        thread::wait
      }
    }
    
    vwait forever
    

    This code creates one logger thread and four worker threads each of which posts a message to the logger thread once per second. The code runs until manually interrupted. The logger thread just simple-mindedly outputs the message it was passed to the console, but as someone else in this thread already mentioned, you could probably use the “logger” package from Tcllib, if you need fancy stuff like facilities.

    To reiterate my points:

    • The logger package itself does not presumably know anything about threading.
    • Tcl threads are well-separated and usually communicate via message passing.
    • Hence create a thread for the logger and teach worker threads send messages to it; therefore working threads are not concerned with how logger is implemented.

    P.S. In the worker threads, you can use [thread::send -async ...] to make sending log messages fully asynchronous.

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

Sidebar

Related Questions

I need a lightweight logging library for ASP.NET MVC2. It only needs to support
I need some clever logging library for a daemon-like C (not C++ ) program
I have a library, which uses Common.Logging. I need to get my code called
I need a logging framework in my application. I have two candidates: Log4Net and
I have the following need I have a logging table which logs som leads
I need to know, whether extjs 3.1 is available of exception handling and logging
I've run into a situation (while logging various data changes) where I need to
Can anyone recommend a .Net XML Serialization library (ideally open source). I am looking
TL;DR version: What do you use for configurable (and preferably captured) logging inside your
I am using Apache Common Logging library in my standalone application. After searching through

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.